I have been dealing with some really really weird issues lately. In the end I concluded that they were caused by memory issues (not enough). But I don't really understand why... Can anyone help shine light on these things?
The project I am currently working on is using a GPS module and a small OLED display. If I run a test program (without changing any wires) that only interacts with the GPS module (write info to the serial monitor instead of OLED) it works on both an UNO and an MEGA. If I run another test program (again without changing any wires) that only interacts with the OLED it runs fine on both an UNO and an MEGA. If I then run the main project that interacts with the OLED and the GPS it only works on a MEGA... I tried three UNO's and I get the same result. I know that the OLED is memory hungry so that is why I suspect the problem is related to the limited memory on an UNO. [FYI: The GPS module is connected to pins 10/11 and the OLED is connected to SDA/SCL. In case of the UNO I use the SDA/SCL on A4/A5 and on the MEGA I use the SDA/SCL on pins 20/21].
But if I look at the IDE info I get when I upload the program to the UNO and MEGA it is not clear that there is an issue:
- UNO: Sketch uses 20362 bytes (63%) of program storage space. Maximum is 32256 bytes. Global variables use 772 bytes (37%) of dynamic memory, leaving 1276 bytes for local variables. Maximum is 2048 bytes.
- MEGA: Sketch uses 20852 bytes (8%) of program storage space. Maximum is 253952 bytes. Global variables use 772 bytes (9%) of dynamic memory, leaving 7420 bytes for local variables. Maximum is 8192 bytes.
So, what is going on here? I am uploading the exact same sketch to both the UNO and the MEGA. Thank you!