Logging non GPS data toAdafruit Ultimate GPS Logger Shield

Adafruit Ethernet, Motor, Proto, Wave, Datalogger, GPS Shields - etc!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
User avatar
jboyton
 
Posts: 101
Joined: Tue Sep 16, 2014 2:52 pm

Re: Logging non GPS data toAdafruit Ultimate GPS Logger Shie

Post by jboyton »

It's possible I missed something, but removing literal strings wasn't enough when I tried weeks ago. When I added the BMP code to the SD shield code with almost all Serial.print() statements removed the sketch just kept resetting.

From my notes:

GPS/SD: shield_sd_log used 22.4K code and 1654 bytes of ram
BMP: sensorapi used 10.2K code and 805 bytes of ram

Removing all serial.print() except for one to display free memory from sensorapi saved 150 bytes of ram.
Removing all serial.print() and serial.begin() from shield_sd_log saved 88 bytes of ram.

The total ram saved was short of what was needed by at least 173 bytes.

You might be able to squeeze a couple hundred more bytes in some other way.
I had an entire other library to add to my project so there was no way for me without deeper cuts.

Coloradomojo14
 
Posts: 9
Joined: Wed Jul 16, 2014 7:28 am

Re: Logging non GPS data toAdafruit Ultimate GPS Logger Shie

Post by Coloradomojo14 »

We will be happy to take any examples or suggested code anyone is willing to pass along.

Greatly appreciate everyone's willingness to help with this project.

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

Re: Logging non GPS data toAdafruit Ultimate GPS Logger Shie

Post by adafruit_support_bill »

Have you trimmed down the serial port buffer? That is another fairly easy one mentioned in the guide. If jboyton's code doesn't get you there, post what you have and we'll look for other possible ways to trim it.

Another way out might be to move to a Leonardo. That has 2.5K of SRAM.

Coloradomojo14
 
Posts: 9
Joined: Wed Jul 16, 2014 7:28 am

Re: Logging non GPS data toAdafruit Ultimate GPS Logger Shie

Post by Coloradomojo14 »

Did some work this weekend. In theory we should have 200 byes of SRAM available after merging the GPS and Pressure sketches but it crashes (does not open the file on the SD card).

Any suggested sketchs would be greatly appreciated. Unfortunately we are running out of time to get a Leonardo and integrate the GPS logger shield. My son believes that the GPS Ultimate Logger shield is only partially compatible with the Leonardo.

Thanks.

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

Re: Logging non GPS data toAdafruit Ultimate GPS Logger Shie

Post by adafruit_support_bill »

SRAM usage is dynamic. It is needed for the stack as well. Opening a file on the SD card requires 512 bytes for the SD block buffer.
My son believes that the GPS Ultimate Logger shield is only partially compatible with the Leonardo.
That is true for both the Leonardo and the Mega. You need to use "software SPI". It is somewhat slower than the hardware SPI solution.

If you post your code, we may be able to identify other candidates for optimization.

User avatar
jboyton
 
Posts: 101
Joined: Tue Sep 16, 2014 2:52 pm

Re: Logging non GPS data toAdafruit Ultimate GPS Logger Shie

Post by jboyton »

Measuring the free ram is a little tricky. You can get different results depending on how you do it. But I didn't find that opening a file with SD eats up 512 bytes. Those bytes seem to already be reserved before the call to open().

I wonder how close you are to making it fit?

Attached are some drop-in replacements for Adafruit_GPS and SoftwareSerial, pared down versions of the originals that I created to find out how much I could save by taking "scissors" to the libraries. I have since replaced both of them in my project, but these are easier to simply hand to you than what I'm using now. The GPS code is the same but with the locus code removed. The soft serial code is modified to only support 9600 baud. All you'll have to do to try these is change the names of the include files and the constructors to match the new ones. I just did a test build using shield_sdlog and using these two libraries saved 141 bytes of ram.

Replacing SD with SdFat saved another 65 bytes of ram. SD is just a wrapper for an old version of SdFat. SdFat is on github. It isn't a drop-in replacement for SD but the required code changes are minimal. Look at the datalogger example to see what you need to do.

Without seeing your sketch it's hard to know whether there are other things you could try, or if 141 (or 206) bytes is enough.

Good luck.
Attachments
SoftSerial_BASIC.cpp
(6.01 KiB) Downloaded 118 times
GPS_BASIC.h
(2.74 KiB) Downloaded 136 times
GPS_BASIC.cpp
(7.17 KiB) Downloaded 132 times
Last edited by jboyton on Mon Nov 17, 2014 10:04 pm, edited 6 times in total.

User avatar
jboyton
 
Posts: 101
Joined: Tue Sep 16, 2014 2:52 pm

Re: Logging non GPS data toAdafruit Ultimate GPS Logger Shie

Post by jboyton »

Here's the fourth one, there's a 3 file limit on this forum.
Attachments
SoftSerial_BASIC.h
(1.58 KiB) Downloaded 124 times

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

Return to “Arduino Shields from Adafruit”