Interfacing OLED display with ESP32

When it comes to adding a small and crisp display to your embedded project, OLED screens are a perfect choice. In this post, we’ll learn how to interface a 0.96″ I2C OLED display with an ESP32 board and display custom text on it.


Why Use an OLED Display?

OLED (Organic Light Emitting Diode) displays are:

  • Lightweight and compact
  • Low power consumption
  • High contrast (perfect for both indoor and outdoor viewing)
  • Easy to connect over I2C protocol

This makes them ideal for IoT projects, dashboards, and wearable devices.


What You’ll Need

  • ESP32 Development Board
  • 0.96″ I2C OLED Display (SSD1306 driver)
  • Jumper Wires
  • Breadboard
  • Arduino IDE (or PlatformIO)

Wiring Diagram

Connect the OLED display to ESP32 as follows:

  • GND → GND
  • VCC → 3.3V
  • SCL → GPIO22
  • SDA → GPIO21

(Note: Some boards might use different I2C pins. Always check your ESP32 variant.)

Coding Steps

  1. Install the Adafruit SSD1306 and Adafruit GFX libraries from Arduino Library Manager.
  2. Include the necessary libraries in your sketch: cppCopyEdit#include <Wire.h> #include <Adafruit_GFX.h> #include <Adafruit_SSD1306.h>
  3. Initialize the display: cppCopyEditAdafruit_SSD1306 display(128, 64, &Wire, -1);
  4. Setup and display text: cppCopyEditvoid setup() { display.begin(SSD1306_SWITCHCAPVCC, 0x3C); display.clearDisplay(); display.setTextSize(2); display.setTextColor(WHITE); display.setCursor(10, 20); display.println("Hello ESP32!"); display.display(); } void loop() { // Nothing here for now }

Final Output

If everything is wired correctly and your code uploads successfully, you should see “Hello ESP32!” on your OLED display.


What’s Next?

In upcoming blogs, we’ll explore how to:

  • Create dynamic displays (sensor values, animations, etc.)
  • Customize fonts and graphics
  • Build mini GUIs for your projects!

🚀 Stay tuned and keep tinkering!
If you have any questions or want to show off your projects, feel free to drop a comment or reach out to me!

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top