Display stops working after a few seconds, ESP32 NodeMCU
Closed this issue · 1 comments
AnanasPizza commented
I'm using the library on an ESP32, trying to display new data on every loop, without any delay calls.
The code below is obviously very stripped down.
It's connected to 21 and 22 pins. As well as a Real Time clock, a TCS Light sensor, and a SCD30.
The issue is, that after a few seconds/minutes, this happens:
Is this a RAM Error?
After compilation this is the RAM and Flash Usage
RAM: [= ] 12.4% (used 40524 bytes from 327680 bytes) Flash: [========= ] 85.1% (used 1115840 bytes from 1310720 bytes)
#include <Wire.h>
#include <Adafruit_SSD1306.h>
void setup() {
Wire.begin();
initializeDisplay();
}
void loop() {
...
writeToDisplay(.......);
}
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define SCREEN_ADDRESS 0x3C
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
bool initializeDisplay() {
if (!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
return false;
}
display.display();
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(0, 0);
display.println("Display initialized!");
display.display();
display.clearDisplay();
return true;
}
void writeToDisplay(float colorTemp, float lux, float dbValue, String temperature, String relH, String co2) {
display.clearDisplay();
displayText ="";
displayText += "Lux ";
displayText += String(lux,1);
displayText += "lx\n";
displayText += "Color Temp. ";
displayText += String(colorTemp, 1);
displayText += "K\n";
displayText += "Noise level: ";
displayText += String(dbValue, 1);
displayText += "dbA\n";
displayText += "Temperature: ";
displayText += temperature;
displayText += "C\n";
displayText += "relH ";
displayText += relH;
displayText += "%\n";
displayText += "CO2 ";
displayText += co2;
displayText += "ppm\n";
if(isPortable()) {
displayText += "Portable Mode";
}
display.println(displayText);
display.display();
}
ladyada commented
hiya, this is a good question to post to the espressif forums or whomever you purchased hardware from. thanks :)