Update:
I found the origin of my problem. The problem was due to the fact that I use 12v convert to 5v to power my Esp32. To convert the 12v I use a L7805 with 4 capacitors. This implies a slight delay to reach the 5V. This meants that the ESP32 booted before the voltage was 5V (and before 3.3V). The ESP32 has enough voltage to boot but not the display. To fix that, I simply add a delay before load the screen.
Hello,
I have been working for a long time on a project for my daughter. I am creating a connected RGB lamp that can be managed from a small OLED screen (selection of the color, rainbow mode, ...) . I'm already quite advanced in the project (printed case, printed pcb, ...), but I have a problem that bothers me a lot.
When I upload my code, everything works perfectly. My screen lights up. However, if I restart the ESP, my screen doesn't turn on. I have to do a reset.
Do you have any idea what the problem is? I'll not copy/paste all my code (~ 800 lines), but I'll give you the setup method (which seems to me the most important).
My setup:
- Board: Esp32-C3-Devkits-C
- Screen: Monochrome 0.96" 128x64 OLED Graphic Display - STEMMA QT (product Adafruit 326) connected with I2C
- Libraries used for the screen: Adafruit_SSD1306.h and Adafruit_GFX.h
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <RotaryEncoder.h>
#include <Preferences.h>
// A lot define and variables
Preferences preferences;
void setup() {
Serial.begin(115200);
while (!Serial);
I2CSSD1306.begin(I2C_SDA, I2C_SCL);
display = Adafruit_SSD1306(SCREEN_WIDTH, SCREEN_HEIGHT, &I2CSSD1306, OLED_RESET);
if (!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
Serial.println(F("SSD1306 allocation failed"));
for (;;)
;
}
loadValues();
attachInterrupt(PIN_ENCODER_A, checkPosition, CHANGE);
attachInterrupt(PIN_ENCODER_B, checkPosition, CHANGE);
pinMode(BUTTON_UP, INPUT_PULLUP);
pinMode(BUTTON_DOWN, INPUT_PULLUP);
pinMode(BUTTON_LEFT, INPUT_PULLUP);
pinMode(BUTTON_RIGHT, INPUT_PULLUP);
pinMode(BUTTON_IN, INPUT_PULLUP);
display.display();
delay(2000); // Pause for 2 seconds
// Clear the buffer
display.clearDisplay();
lastClickTime = millis();
lastColorChange = millis();
ledcSetup(RED_CHANNEL, freq, resolution);
ledcSetup(GREEN_CHANNEL, freq, resolution);
ledcSetup(BLUE_CHANNEL, freq, resolution);
ledcSetup(WHITE_CHANNEL, freq, resolution);
ledcAttachPin(RED_PIN, RED_CHANNEL);
ledcAttachPin(GREEN_PIN, GREEN_CHANNEL);
ledcAttachPin(BLUE_PIN, BLUE_CHANNEL);
ledcAttachPin(WHITE_PIN, WHITE_CHANNEL);
changeLed();
printScreen();
}
void loop() {
checkButtons();
checkSelection();
checkScreen();
delay(200);
}
There is the electric schema of my project
If you can help me, I will be very grateful. I would like to be able to finally give this gift to my daughter.
Thank you,
Sylvain

