SSD1306 0.96 inch OLED stopped working

I was able to make my I2C SSD1306 OLED work with an ESP32 but after a few minutes with an USB battery plugged into the ESP32, the display stopped working.

I then plugged back the ESP32 into my PC and re-uploaded my code, but the display still refuses to work.

The display stills responds on I2C address 0x3C, as shown by this I2C scanner code :

#include <Wire.h>
 
void setup() {
  Wire.begin();
  Serial.begin(115200);
  Serial.println("\nI2C Scanner");
}
 
void loop() {
  byte error, address;
  int nDevices;
  Serial.println("Scanning...");
  nDevices = 0;
  for(address = 1; address < 127; address++ ) {
    Wire.beginTransmission(address);
    error = Wire.endTransmission();
    if (error == 0) {
      Serial.print("I2C device found at address 0x");
      if (address<16) {
        Serial.print("0");
      }
      Serial.println(address,HEX);
      nDevices++;
    }
    else if (error==4) {
      Serial.print("Unknow error at address 0x");
      if (address<16) {
        Serial.print("0");
      }
      Serial.println(address,HEX);
    }    
  }
  if (nDevices == 0) {
    Serial.println("No I2C devices found\n");
  }
  else {
    Serial.println("done\n");
  }
  delay(5000);          
}
Scanning...
I2C device found at address 0x3C
done

Then, whatever I do, the display stays black. For instance, this code does not display anything, while it was working before.

#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels

// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);

void setup() {
  Serial.begin(115200);

  if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3D for 128x64
    Serial.println(F("SSD1306 allocation failed"));
    for(;;);
  }
  delay(2000);
  display.clearDisplay();

  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.setCursor(0, 10);
  // Display static text
  display.println("Hello, world!");
  display.display(); 
  Serial.println("Done writing to screen !");
}

void loop() { 
}

I also checked that I had 3.3v between the Vcc and Gnd pins of the screen, and that is the case. So there does not seem to be any wiring issues. The SCL pin is connected to GPIO22 and the SDA pin to GPIO21.

It seems that the display is broken after a few minutes of working properly.

Is it common for this kind of displays to be so fragile ? Is it likely to be a software issue ?

The communication with the controller seems to be fully functional, I tried to send the display buffer contents via serial, and it is indeed altered when I write text.

#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels

// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);

void setup() {
  Serial.begin(115200);

  if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3D for 128x64
    Serial.println(F("SSD1306 allocation failed"));
    for(;;);
  }
  delay(2000);
  display.clearDisplay();
  for(int x = 0; x < 128; x++) {
    for(int y = 0; y < 64; y++) {
      Serial.print(display.getPixel(x, y));
    }
    Serial.println();
  }
  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.setCursor(0, 10);
  // Display static text
  display.println("Hello, world!");
  display.display(); 
  Serial.println("Done writing to screen !");
    for(int x = 0; x < 128; x++) {
    for(int y = 0; y < 64; y++) {
      Serial.print(display.getPixel(x, y));
    }
    Serial.println();
  }
}
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
[... remainder of buffer omitted for clarity]
Done writing to screen !
0000000000111111100000000000000000000000000000000000000000000000
0000000000000100000000000000000000000000000000000000000000000000
0000000000000100000000000000000000000000000000000000000000000000
0000000000000100000000000000000000000000000000000000000000000000
[... remainder of buffer omitted for clarity]

Hi @hkl6 , I've done lots of silly wiring while watching TV on a few OLED's and even burnt my finger on one last week, it died but came back to life after it cooled down, I've never managed to break one though(all on 5v). Fragile they are not from my point of view.

Welcome to the forum, Phil.

Thank you for the reply (and the welcome message), I appreciate it. So unlikely to be a hardware issue. But the software seems fine..

Maybe you happen to have a dud? your code works on mine, just tested it.

That was the right answer. I bought a new SSD1306 0.96 inch display and swapped it with the old one without changing the code or anything else, and it works.
So if someone is reading this in the future: if your OLED display stops displaying anything but still replies on I2C, your code / circuit is probably right and you display is probably dead.

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