SSD1306 OLED display 128×64 (I2C)
A 128 × 64 dot OLED screen whose dots light up on their own (no backlight). It talks to the ESP32 over I2C (only 2 data wires: SCL and SDA). The ssd1306.py driver does NOT come in the firmware: copy the file to the board first. You draw in memory (text, dots, rectangles) and it only shows on the screen with oled.show(). Careful: the pin order changes from maker to maker (VCC and GND swapped).
Pinout
| Pin | Connect to | Note |
|---|---|---|
| GND | GND | check the order printed on YOUR module |
| VCC | 3V3 | on some modules VCC comes before GND |
| SCL | GPIO22 (wiring used in the example) | I2C clock |
| SDA | GPIO21 (wiring used in the example) | I2C data |
The AI that remembers your life and lives on your computer
- Long-term memory with the source of every answer
- Works offline: your data stays on your PC
- Reads PDFs, slides, photos and meeting recordings
Essential plan free forever
MicroPython example
# FIRST: copy ssd1306.py (micropython-lib) to the board — it does not come in the firmware.
from machine import Pin, I2C
import ssd1306
import time
# wiring used here (common on the DevKit): SCL on GPIO22 and SDA on GPIO21
i2c = I2C(0, scl=Pin(22), sda=Pin(21))
print(i2c.scan()) # the OLED answers at 60 (0x3C)
oled = ssd1306.SSD1306_I2C(128, 64, i2c) # address 0x3C
oled.fill(0) # clears everything (in memory)
oled.text("Hello, ESP32!", 0, 0) # the 8x8 font has no accents
oled.rect(0, 16, 128, 48, 1) # frame
oled.show() # now it shows on the screen
n = 0
while True:
oled.fill_rect(8, 32, 112, 8, 0) # clears only the counter line
oled.text("counter: %d" % n, 8, 32)
oled.show()
n += 1
time.sleep(1)
Specifications
| Item | Value | Source |
|---|---|---|
| Resolution | 128 × 64 dots | PyPlaca component catalog |
| I2C address | 0x3C (alternative 0x3D) | Typical datasheet values |
| Pin order | GND, VCC, SCL, SDA — varies by maker (variant with VCC and GND swapped) | Typical datasheet values |
| Driver | ssd1306.py — copy it to the board | Typical datasheet values; micropython-lib: micropython/drivers/display/ssd1306/ssd1306.py |
| Power supply | 3.3 V in the simulator | PyPlaca component catalog — Under review: module VCC range (does it accept 5 V?) |
| Pull-up on SDA/SCL | there are modules with and without the resistors (a property of the part); without a pull-up I2C does not work | PyPlaca component catalog — Under review: check on the lab module |
| Screen color | white in the simulator | Under review: there are blue and yellow + blue modules — which one is in the lab? |
Values marked "Under review" will still be checked against the parts in the lab.