OLED example sketch works on small OELD but same model in larger size acts strange

The small OLED works, the slightly larger ones dont.



This is my code:

/*
 * This ESP32 code is created by esp32io.com
 *
 * This ESP32 code is released in the public domain
 *
 * For more detail (instruction and wiring diagram), visit https://esp32io.com/tutorials/esp32-oled
 */

// SDA 20
// SCL 21

#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

int lines = 0;

// 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(500);
  display.clearDisplay();

  display.setCursor(0, 5);
  display.setTextSize(1.2);
  display.setTextColor(WHITE);
  
  
  // Display static text
  blinkText("Hello Laith,");

  blinkText("How are you today?");

  blinkText("How was your day?");

  blinkText(".");
  blinkText(".");
  blinkText(".");
  blinkText(".");
  blinkText(".");
  blinkText(".");
  blinkText(".");
  blinkText(".");
  blinkText(" :) ");
  
}

void loop() {
  
}

void blinkText(String text) {
  if(lines == 7) {
    display.clearDisplay();
    display.setCursor(0, 5);
  }

  //display.setCursor(0, 5);
  display.println(text);
  display.display(); 

  delay(1000);
  lines++;
  // display.clearDisplay();
}


It would appear that the larger OLED doesn't use an SSD1306 controller. You'll have to include the library that matches whichever controller it uses.

1 Like

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