SSD1306 Oled, working in a project but not in another


I have modified an arduino project (using an arduino Nano) in order to use an I2C SSD1306 Oled screen as a replacement of an old LCD 20x4 I2C.
Source project : Trimix-analyzer/trimix-analyzer.ino at master · captainigloo/Trimix-analyzer · GitHub
Schematic :

All the wiring is correct, and I have been able to run the code on an ESP32 without any problem.

Then I tried to swap the ESP32 with the arduino nano and uploaded the code ==> I obtain the "SSD1306 allocation failed" message
I used the SSD1306 example project, modified to display some of the informations I need in my project, without changing any wiring or hardware part, and keeping the same I2C address ==> The display is working !

Then I tried a copy/paste of the includes and the setup(), in order to eliminate a potential error ==> the same, the screen is not working and still "allocation failed"...

I tried to comment some parts of the main project (the ADS1115 references, for example) ==> screen still not working...

I can't find a way to have it working...

Can someone help me ?

Thank you.

PS: The "main" project that is not working is "Analyseur_trimix_martin.ino"
The "test" project is "ssd1306_......test_ecran.ino"

Both are uploaded with this post
I use the latest version of all the librairies included.

Analyseur_trimix_oled_martin.ino (10.2 KB)
ssd1306_128x64_i2c_test_ecran.ino (7.0 KB)

There are quite a lot of anonymous strings e.g.
display.println(" Calib. en cours");
These get copied to SRAM which just wastes memory.
Use the F() macro to ensure that they are printed from Flash memory.
display.println(F(" Calib. en cours"));

The Uno has only got 2048 bytes of SRAM. It "looks" safe at compile-time. But an extra 1024 bytes of SRAM are allocated at run-time.


Spot on !

I would never have found this kind of "error".
and I've learned something with the "F" macro.

Thank you very much for your help !

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.