ESP32 Example

ESP32 OLED I2C Example

Display text on SSD1306 OLED.

Wiring

Check pinout, power supply, common GND and voltage levels before connecting the module.

Full code

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

Adafruit_SSD1306 display(128, 64, &Wire, -1);

void setup() {
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  display.clearDisplay();
  display.setTextColor(SSD1306_WHITE);
  display.setTextSize(2);
  display.setCursor(0, 10);
  display.println("ESP32");
  display.display();
}

void loop() {}

How it works

This lesson matches the page title and gives a clean starting point for this exact example.

Common mistakes

Check board selection, wiring, libraries, power supply and serial monitor baud rate.

Frequently asked questions

Can I copy this code?

Yes. Adapt pins, credentials and libraries for your board.

Why does it not compile?

Install required libraries and select the correct board.