Understanding "SSD1306 allocation failure" - Arduino Nano Old bootloader - using ADAfruit library
My latest ongoing project uses a ssd1306 OLED as a message board to display values of temperature sensors, status messages, alarms, etc..
The project is going well, becoming an obsession, adding useful features and ideas, however I kept banging into times where the latest code additions wouldn't execute fully, some IO wouldn't update, and extreme cases where the SSD1306 totally stopped working after an upload of new code.
I'd have to go backward to the previous working code to fix. The IDE compilation errors window had no errors.
I did eventually discover the "SSD1306 allocation failed " message in the serial monitor.
This is one section of the code that calls to display data to the SSD1306:
float DHT11_humidity= dht11.readHumidity();
// read temperature as Celsius
float DHT11tempC = dht11.readTemperature();
// read temperature as Fahrenheit
float DHT11tempF = dht11.readTemperature(true);
// check if any reads failed
if (isnan(DHT11_humidity) || isnan(DHT11tempC) || isnan(DHT11tempF)) {
Serial.println("Failed to read from DHT11 sensor!");
}
/// display readings to the SSD1306 OLED /////
display.clearDisplay();
delay(ScreenClearDelay);
display.setCursor(0, 10);
// Display static text
display.println("Humidity");
display.println(" %");
display.println(DHT11_humidity);
display.display();
delay(ScreenOnTime);// for reading display
display.clearDisplay();
delay(ScreenClearDelay);
display.setCursor(0, 10);
// Display static text
display.println(" DHT11");
display.println("temp F=");
display.println(DHT11tempF);
display.display();
delay(ScreenOnTime);// for reading display
ScreenOnTime is 3000msec. ScreenClearDelay is 250 msec.
The program had 11 to 13 information screens like this printed to SSD1306 using more code just like this portion.
After commenting out an extraneous SSD1306 screen prints, new code was able to be added and IO working.
There is some limit to how many times the SSD1306 can be called upon to display info, or what can be displayed.
The allocation message seems more of "can the SSD1306 talk to the address 0x3C" than not enough room for all this simple text. I did see one hint in the Arduino forum to suggest removing SSD1306 screens from the code to avoid this allocation message.
Looking for advice for understanding exactly what the library message is, quantify the number of text screens or memory needed ( which maybe can lead to me to make the code more efficient ), or understand if to change the platform from the old Nano to a newer Arduino with more memory.