After compiling the Project “How to add GPS to your Arduino”, when I upload and try to run the project, I get the error message “SSD1306 allocation failed”.
If I load the test program from examples "ssd1306_128x32_I2C, the display initialises and works.
Both the project and the example contain the same line to get the display ready,
I’d start by narrowing down the hardware and library details before blaming the compass or the bus.
Could you post:
the exact Arduino board selected in the IDE
the exact OLED module you’re using
a photo of your setup, with a particular attention to wiring.
Since the ssd1306_128x32_I2C example runs, that at least suggests the display and wiring are basically alive. The useful next step is checking whether the project sketch is set up for the same display parameters and board environment as the working example. Once those details are up, it should be much easier to pin down.
I would be interested in the amount of free memory.
Without knowing the actual hardware in use most screens will attempt to grab some memory are run time when you setup the display. If the sample code works but a bigger project does not, it could be linked to free memory… i.e. the sample project is using less, thus enough.
While I don’t know, their should be a command to output the amount of free memory.
I have done a bit of digging, seems memory is a problem (UNO R3) and apparrently when using Software Serial with I2C on the R3, there is a conflict. Does not happen on the R4.
Thank you for your reply. I have been doing some research and I believe I have two problems.
I was using a UNO R3 and when I load the full program, memory runs almost out, as well I read that there is a conflict with using Software Serial and I2C. All these problems will hopefully go away when I get a R4.
The Adafruit SSD1306 library fails due to insufficient SRAM. Your Arduino Uno has only 2KB RAM total. The display buffer alone consumes up to 1024 bytes. GPS libraries like TinyGPS++ add significant memory overhead. Example works because it uses minimal additional memory.
Your project exceeds available SRAM, causing allocation failure. The display size should match hardware, 128x32 not 128x64. Use F() macro to store strings in flash memory.
Remove unnecessary buffers and large global variables. Consider upgrading hardware or optimizing memory usage aggressively.