[SOLVED] The screen only lights up when I reset the ESP

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

Welcome to the forum

Right click in the code in the IDE and select "Copy for forum" and paste it here in a post. The code tags will be added automatically

Hi,

Thank for your reply, but this sentence was wrong. It was more like "I'll not copy/paste all my code". However, thank to take to time to read my topic :slight_smile:

Sylvain

So, how far does the code get when you reset the ESP32 ?

Some Serial.print()s would tel you

Apart from the screen not turning on, there is no difference between a simple boot and a reset. My buttons work in both cases and I have outputs on stdout.

I put outputs in several places in the code and they display correctly in both cases.

Hi,

I haven't found the source of the problem yet, but I'm pretty sure that it is a problem with the fact that I use a custom pins (SDA and SCL) for my oled screen.

I tried with the following modification:

  • Use the default TwoWire instance (use the pointer &wire) instead of create my own instance
  • Call the method begin on the Wire before call the method begin on display
  • Set the parameter reset to false and periphBegin in the call of begin on display

Any help would be very helpful. I'm starting to despair

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