1306 OLED and ESP32

Hi. I'm running Windows 10 with PlatformIO and tried this simple "Hello World"

#include <Arduino.h>
/*********
  Rui Santos
  Complete project details at https://randomnerdtutorials.com  
*********/

#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(); 
}

void loop() {
  
}

I get this:

I tried a second display and the outcome was the same. I also tried the other I2C connection and also got the same thing. Any help is appreciated!

Mark

Try running an I2C scanner sketch to confirm the display’s address.

https://raw.githubusercontent.com/RuiSantosdotme/Random-Nerd-Tutorials/master/Projects/LCD_I2C/I2C_Scanner.ino

FYI

first thing I did. The address is correct

Okay, if you got a response with the scanner sketch then that proves ~90% of the hardware .

Suggest you confirm there are I2C pull-ups are on the display PCB.

Experiment with adding 4.7k on both SCL and SDA going to 3V3.


BTW, the soldering on A0-A3 is iffy but this should not affect I2C.

This is interesting...I used a different EMC-32 board and got the same thing. I did what you suggested on the 4.7K pullups...no effect.

This is odd.

If you have a completely different I2C device (maybe an RTC), try it on the controller to see if it works.

Good idea. I do have a RTC. Will let you know.

you program works OK on a ESP32 NodeMCU ESP-WROOM-32

edit: looking at the photo in post 1 it does not like you have LCD GND connected to ESP32 GND and VCC to 3.3V
perhaps it is the angle of the camera?

All - I found a couple of posts on other forums e.g. (Troubleshooting — Luma.OLED: Display drivers for SSD1306, SSD1309, SSD1322, SSD1362, SSD1322_NHD, SSD1325, SSD1327, SSD1331, SSD1351, SH1106, SH1107, WS0010, WINSTAR_WEH 3.11.0 documentation) where people were using the wrong drivers (for a different display). One in particular purchased an SSD1306 only to find he was given an SH1106. So for fun I downloaded the library U8g2, set it to SH1106 and it worked!

I then went back on amazon and reported the idiot who I bought them from since the description clearly said SSD1306.

1 Like

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