Memory issues with Uno datalogger with SD card and Adafruit FONA SIM800H chip

Hi,

I have a datalogger with real time clock and SD card. I recently added a FONA SIM800H shield from Adafruit and when I merged the two sketches I ran into dynamic memory issues.

Global variables use 1,765 bytes (86%) of dynamic memory, leaving 283 bytes for local variables. Maximum is 2,048 bytes.
Low memory available, stability problems may occur.

I F() all the serial.print and try to move global variables into the loop or other functions when possible.
These solutions freed very limited amounts of dynamic memory (went from 87% to 86% used).

I am thinking of 2 solutions:

  1. Buy a Mega.
    Would I be able to use the same shields that I am using with the Uno? Can I use the same sketches?

  2. Keep improving my sketch but I wonder how much dynamic memory should I free for my sketch to be stable. Do I need to reduce the use of dynamic memory down to 85%? 70%?

Any help is greatly appreciated!

Thanks!

Jerry

Would I be able to use the same shields that I am using with the Uno?

Most likely.

Can I use the same sketches?

Some changes might be needed. For instance, you don't need to use SoftwareSerial on the Mega.

  1. Keep improving my sketch but I wonder how much dynamic memory should I free for my sketch to be stable. Do I need to reduce the use of dynamic memory down to 85%? 70%?

Keep reducing memory usage until the message about instability goes away.

Post your code. There may be things you are overlooking.

Hi Paul,

thanks! Here is my code:

Any help is greatly appreciated!

Jerry