ultimate GPS to track sea turtle

General project help for Adafruit customers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
User avatar
albertoabreu
 
Posts: 14
Joined: Thu Jul 25, 2013 12:10 am

ultimate GPS to track sea turtle

Post by albertoabreu »

We are building a tracking system with an Arduino UNO with the Ultimate GPS shield which we recently put together. This will be housed inside a float attached by a fishing line to juvenile sea turtles in coastal lagoons. The objective is to track the movements of the turtles over a period of days to locate preferred habitats and improve our conservation efforts. A critical aspect in the system is battery lifetime as we will need to retrieve the float every time batteries need replacing. Although we have the GPS shield working nicely and have been able to perform some of the basic commands using the supplied shield_sdlog sketch (thank you very much!) and can get one reading every 10 seconds, we would ideally like to be able to access the GPS's ability to enter PERIODIC MODE to only get location fixes once every 2-5 minutes to save power as much as possible. So far we haven´t been able to get into that mode using the Arduino sketch. Also, we don't have much programming experience and are confused as to how to coordinate the periodicity of the GPS function with the possibility of the Arduino going into and out of sleep.

Maybe someone out there has experience with this control and has coding they could share with us, or could point us towards a reference source in the internet. Many thanks in advance!

Alberto

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: ultimate GPS to track sea turtle

Post by adafruit_support_rick »

Interesting. I have no experience with periodic mode - I just had to go look it up. I think you want periodic mode '2'.
You want to set the 'first run time' to be long enough to reliably get a fix when coming out of sleep. You'll have to come up with that number empirically.
You want to set the 'first sleep time' to your 5-minute interval (300,000 milliseconds). Leave the 'second run time' and 'second sleep time' as 0.

The standard sleep procedure on the Arduino uses the watchdog timer to wake the CPU. The maximum sleep interval is 8 seconds. So, it's easy to put the sleep routine in a loop with a counter. Keep going back to sleep until the counter reaches 38 (assuming a 5:04-minute GPS sleep), then start listening to the GPS. Wait for a fix, get your location, and go back to sleep.

You can adjust your sleep counter to include the additional time the GPS spends in 'first run time' before you get your fix. For instance, if 'first run time' is 60 seconds, and it takes 15 seconds to get a fix, then increase your sleep counter by 5 to account for the extra 45 seconds spent in run time before sleep begins again. You can track that time using the Arduino timer.

As long as your code waits for a fix and correctly accounts for the GPS run time and sleep time, you should always be able to stay synchronized with the GPS sleep period.

User avatar
albertoabreu
 
Posts: 14
Joined: Thu Jul 25, 2013 12:10 am

Re: ultimate GPS to track sea turtle

Post by albertoabreu »

Yay, thanks for replying Rick!! I have done a few trial runs following what you describe but did not include the watchdog timer because I am not familiar with it. I was able to put the gps into periodic standby using the direct mode switch and sending the commands over the serial cable. However, these were not retained in the gps when I switched back to Arduino control. Would I need to include the PMTK commands in Adafruit_GPS.h? I had problems doing so because my new #define statements were not recognized by the sketch. In the end I cheated by copying my commands (e.g. $PMTK225,2,10000,50000,0,0*2D) over the previously defined #defines (e.g. #define PMTK_AWAKE). That seemed to go through and now I am testing the Arduino-GPS. The command I am trying will be on for 10 secs then sleep for 50. In my prior runs, with the GPS near a window, I found that in the 10 secs it comes out of standby and enters a fix per second, the first 7 or so messages indicate no fix, but the last 3 are ok. So that time for the awake period seems a safe bet. Extending the standby period seems to be where I can reduce power consumption.

Regarding the watchdog timer, could you point out a sketch where this is used?

When you say that after the watchdog you "Wait for a fix, get your location, and go back to sleep." do you mean that the shield_sdlog sketch with #define LOG_FIXONLY true will only log if a fix comes through? I suppose that the controlling feature is the PMTK periodic standby mode, but then the sketch will continue looping as long as a fix is available and what is going to make it stop and go back to sleep? Sorry for being so ignorant.

Oh, also, can you tell me what command in the shield_sdlog sketch detects that there is a fix?

When I finish editing my sketch I'll post a copy for further corrections and maybe others can benefit, if that's ok.

User avatar
adafruit_support_bill
 
Posts: 88089
Joined: Sat Feb 07, 2009 10:11 am

Re: ultimate GPS to track sea turtle

Post by adafruit_support_bill »

[moved topic to General Project Help]

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: ultimate GPS to track sea turtle

Post by adafruit_support_rick »

Interesting. I've been playing around with this a bit, and I haven't figured out out how to make it behave reliably. I continue tinkering...

User avatar
albertoabreu
 
Posts: 14
Joined: Thu Jul 25, 2013 12:10 am

Re: ultimate GPS to track sea turtle

Post by albertoabreu »

Thanks for spending time on this issue. Other than using the direct mode, as I mentioned earlier, I haven´t been able to put the GPS into periodic standby via the Arduino sketch. Seems to me that something needs tinkering in the Adafruit_GPS cpp and/or h but that is a bit beyond me at the moment.

I trust you can work out the trick! In the meantime I am learning about the watchdog timer.

cheers

Alberto

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: ultimate GPS to track sea turtle

Post by adafruit_support_rick »

OK, I've got a version of the parsing sketch and a version of the shield_sdlog sketch.

It turns out we don't needthe watchdog timer, because we're using SoftwareSerial. SoftwareSerial relies on the hardware pin-change interrupt to work, and the pin-change interrupt will wake the CPU out of power-down mode.

So, what happens is we keep track of the time each character is received from the GPS. When the GPS goes to sleep, we stop receiving characters, and we decide to put the Arduino to sleep if we haven't heard from the GPS for more than 1 second.

When the GPS wakes up, it will start transmitting characters again, which will wake up the Arduino.

Check out the two sketches:
sleep_sketches.zip
(6 KiB) Downloaded 274 times

User avatar
albertoabreu
 
Posts: 14
Joined: Thu Jul 25, 2013 12:10 am

Re: ultimate GPS to track sea turtle

Post by albertoabreu »

Wow, you are so clever. Thanks for the new sketches. I have downloaded both and have tried using shield_sdlog_sleep sketch. The command for periodic mode works fine and I have been able to try a number of time combinations, making sure that the checksum is revised.

What doesn't seem to work well for me is the LOG_FIXONLY adjustment. If I leave it false, even though the GPS gets fixes (or so it reports), there is no logging made and the output to COM is "No Fix".

Here is an output line of what I get on the COM monitor:
$PMTKPMC,0000020250,1,0000000000,0000007930,0000010000,0000000000,0000000000,3,0,0,044*4B
$GPGGA,180616.436,2311.0029,N,10625.5272,W,1,9,0.93,6.8,M,-26.8,M,,*63
OK
No Fix

As you can see, there is a fix, (though I should mention that I adjusted the commands so that only GGA is output) but when I go to the file, nothing is logged.

If I leave LOG_FIXONLY false, the Serial output is very informative, and the data is filed correctly:
$GPGGA,173804.421,,,,,0,0,,,M,,M,,*46
$GPGGA,173805.421,,,,,0,1,,,M,,M,,*46
$GPGGA,173806.444,,,,,0,4,,,M,,M,,*43
$GPGGA,173807.421,2311.0002,N,10625.5585,W,1,5,1.74,4.1,M,-26.8,M,,*6E
$GPGGA,173808.418,2310.9990,N,10625.5446,W,1,6,1.22,6.5,M,-26.8,M,,*69
$GPGGA,173809.418,2310.9983,N,10625.5430,W,1,6,1.22,6.9,M,-26.8,M,,*67
$GPGGA,173810.418,2310.9979,N,10625.5430,W,1,6,1.22,7.0,M,-26.8,M,,*62
$GPGGA,173811.418,2310.9974,N,10625.5430,W,1,6,1.22,7.1,M,-26.8,M,,*6F
$GPGGA,173812.418,2310.9972,N,10625.5430,W,1,6,1.22,7.2,M,-26.8,M,,*69
$GPGGA,173813.419,2310.9970,N,10625.5434,W,1,6,1.22,7.2,M,-26.8,M,,*6F


Since I'd like to optimize battery usage, it would be desirable to avoid unnecessary file entries, but perhaps we can live with that redundancy given that out of the 10 second GPS readings it gets good fixes in a portion of them.

Also, can you tell me if I by changing GPSECHO to false I can reduce power usage when I have the GPS-Arduino disconnected from my computer and solely powered by battery.

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: ultimate GPS to track sea turtle

Post by adafruit_support_rick »

As I recall, the parser only gets the "FIX" status from the RMC command. So, if you've only got GGA, that explains why you're not seeing the fix.
AlbertoAbreu wrote:Since I'd like to optimize battery usage, it would be desirable to avoid unnecessary file entries, but perhaps we can live with that redundancy given that out of the 10 second GPS readings it gets good fixes in a portion of them.
That isn't really going to impact battery usage
AlbertoAbreu wrote:Also, can you tell me if I by changing GPSECHO to false I can reduce power usage when I have the GPS-Arduino disconnected from my computer and solely powered by battery.
Again, that won't affect battery usage, although it's a good idea to turn it off if you don't need it, as it gives the processor less work to do.

User avatar
albertoabreu
 
Posts: 14
Joined: Thu Jul 25, 2013 12:10 am

Re: ultimate GPS to track sea turtle

Post by albertoabreu »

We have a very encouraging advance in our project thanks to your help! We finally figured how the Adafruit_GPS.cpp commands worked and were even successful at identifying the presence of fixes from GPGGA only messages, in analogous ways that it does so from "$GPRMC" strings. But as it happens we decided that for greater efficiency we better stick to $GPRMC only data.

Now that we feel comfortable with controlling the ultimate GPS, we need to move forward with deciding the battery usage. I had a preliminary run with a setup involving a periodic mode of 1HZ sampling, 10 seconds on, followed by 590 seconds off (which would presumably send the Arduino to sleep during the off time). Then I connected a 9V rechargeable battery rated at 200 mAh. This ran for 3.55 hours. Since we are aiming for a run time of at least 24 hours to reduce as much as possible maintenance that implies approaching the tracked turtle it seems it's going to be impossible to improve the Arduino energy usage enough.

Maybe if we use a different battery pack? I wonder if you can enlighten me on alternatives? It seems that we would be better off using AA NiMH batteries that are available at up to 2500 mAh, and combining 6 or 8 to provide 7.2 or 9.6 initial voltages. Could you advice on possible setups and what would be your expectations for run times with other batteries?

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: ultimate GPS to track sea turtle

Post by adafruit_support_rick »

You got 3.5 hours out of a 9V battery? That's pretty good. I'd expect considerably longer out of a pack of NiMH batteries. We have some holders designed to plug directly into an Arduino:
https://www.adafruit.com/products/248
https://www.adafruit.com/products/875

You might also think about unsoldering the power LEDs from the Arduino and the GPS. Also, the RX/TX LEDs on the Arduino and the FIX LED on the GPS.

You might also consider going with something like our FLORA and FLORA GPS receiver. These will run on a 3.7V LiPo battery.
https://www.adafruit.com/product/1059
https://www.adafruit.com/products/659
You'd need a MicroSD module as well:
https://www.adafruit.com/products/254

User avatar
albertoabreu
 
Posts: 14
Joined: Thu Jul 25, 2013 12:10 am

Re: ultimate GPS to track sea turtle

Post by albertoabreu »

I will now be testing the setup with packs of NiMH batteries. Total weight may become a consideration if it interferes significantly with the turtles. So, again, improvements on the power efficiency is still of primary importance.

Unsoldering LEDs from the Arduino and GPS sounds like a good idea. Can you give me a rough idea of how much power consumption could I expect to reduce from this? The power LEDs would obviously be on all the time and therefore would be a great candidate for removal, but the others would only turn on intermittently.

Your suggestion of changing over to FLORA is intriguing. Besides the advantage of using at a lower voltage and with LiPo batteries which have a higher power density, do these boards use power more efficiently than the UNO?

Also, are there other elements in the Arduino UNO which suck up power that can be turned off using software?

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: ultimate GPS to track sea turtle

Post by adafruit_support_rick »

There's nothing besides the CPU that you can turn off in software. The UNO has the additional 16U2 processor that serves as the interface between serial and USB. This extra processor is not present on the Leonardo or FLORA.
The LEDs probably burn a couple of mA, so you'll get a little bit of a boost from unsoldering them.
The FLORA is designed for wearable electronics projects, so it keeps power usage a little more in mind than the regular Arduinos.

User avatar
albertoabreu
 
Posts: 14
Joined: Thu Jul 25, 2013 12:10 am

Re: ultimate GPS to track sea turtle

Post by albertoabreu »

Does the 16U2 processor use power when no USB cable is connected and the Arduino is operating?

There is another option that may be useful for us. From the test runs with 10seconds on and 590 seconds sleep, and assuming that the logged items accurately reflect time spent writing to SD, barely 0.014 of the time is spent logging. My tests indicate that under an outdoor situation, I get plenty of fixes so this scheme is fine. This also means that even over a 4 day period such as we desire to follow a single turtle, barely 1.6 hours of logging would be generated. If so, we could use the internal FLASH logging (LOCUS) instead of writing to the SD. My question to you are (1) if you think this would improve significantly the power usage of the Arduino and (2) if logging to LOCUS can be combined with PERIODIC MODE on the GPS?

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: ultimate GPS to track sea turtle

Post by adafruit_support_rick »

AlbertoAbreu wrote:Does the 16U2 processor use power when no USB cable is connected and the Arduino is operating?
Yes
AlbertoAbreu wrote:If so, we could use the internal FLASH logging (LOCUS) instead of writing to the SD. My question to you are (1) if you think this would improve significantly the power usage of the Arduino and (2) if logging to LOCUS can be combined with PERIODIC MODE on the GPS?
I think it should certainly work with LOCUS.
I don't think it will save a lot of power, because the SD card doesn't use much. However, if you go with the FLORA and the FLORA GPS module, then you wouldn't need a MicroSD breakout at all.

Locked
Please be positive and constructive with your questions and comments.

Return to “General Project help”