Preview build — page text is a draft awaiting human review. Code badges come from real compiles. The flasher is real but not yet hardware-tested; the Playground is still a preview.

1.3″ SH1106 OLED with ESP32 DevKit V1 — U8g2 wiring and code

Drive a 1.3-inch SH1106 I2C OLED from an ESP32 DevKit V1 at 3.3 V on GPIO21/22 with U8g2 — the fix for the noise column the SSD1306 library shows.

Arduino C++Verified — core esp32 3.3.12, U8g2 2.36.19, 3 Nov 2026Compile-only

Community draft — report a mistake

The 1.3-inch OLED is the bigger sibling of the common 0.96″ display and nearly always uses an SH1106 controller. That is why so many people see a stripe of noise when they use SSD1306 code on it.

On the ESP32 DevKit V1 the module runs from 3V3 on the I2C pins D21/D22 (the module calls the clock pin SCK). The sketch uses U8g2 with the proper SH1106 driver and shows a large uptime clock under two lines of text.

Wiring

ESP32 DevKit V1Only the pins used are shown · 3.3 V logicSH1106 OLED 1.3″ (128×64, I2C)GNDD22D213V3VDDGNDSCKSDA
Every connection
ESP32 DevKit V1SH1106 OLED 1.3″ (128×64, I2C)WireNotes
3V3VDDredThe pull-ups go to VDD; 3V3 keeps SDA/SCK at ESP32 levels.
GNDGNDblackCheck the order on your module — some put GND first, some VDD.
D22SCKyellowSCK on this module is the I2C clock (SCL).
D21SDAblue

3.3–5 V (on-board regulator) part, 3.3 V board. Most modules have a regulator and pull-ups to VDD. On ESP32 and Pico power the OLED from 3.3 V so SDA/SCK stay at 3.3 V; on Uno 5 V is fine.

Board quirks

  • Most 1.3″ OLEDs are SH1106, not SSD1306. The SSD1306 library drives them but leaves a 2-pixel column of noise and shifts the image; U8g2’s SH1106_128X64_NONAME driver gets the 132-column RAM right. Why.
  • The full-buffer (_F_) constructor keeps a 1 KB frame in RAM — trivial for the ESP32’s 320 KB, unlike on an Uno where you would pick the page-buffer _1_ version.
  • U8g2 takes the 8-bit I2C address, so 0x3D is set as 0x3D * 2. The sketch probes 0x3C first.
  • The SH1106’s VDD/GND order varies between sellers. Read the print before connecting — reversed power kills the module.

Code

sh1106-esp32.inoArduino C++Open in PlaygroundOpen in PlaygroundFlash
// 1.3" SH1106 128x64 I2C OLED on an ESP32 DevKit V1 with U8g2.
// VDD → 3V3, GND → GND, SCK → D22, SDA → D21. Address 0x3C (some boards 0x3D).
#include <Wire.h>
#include <U8g2lib.h>

// "NONAME" covers the common 1.3" modules; the full-buffer (_F_) mode uses 1 KB RAM.
U8G2_SH1106_128X64_NONAME_F_HW_I2C oled(U8G2_R0, U8X8_PIN_NONE);

void setup() {
  Serial.begin(115200);
  Wire.begin(21, 22);
  Wire.beginTransmission(0x3C);
  bool at3C = Wire.endTransmission() == 0;
  if (!at3C) oled.setI2CAddress(0x3D * 2);  // U8g2 takes the 8-bit address
  oled.setBusClock(400000);
  oled.begin();
  Serial.printf("SH1106 at 0x%02X\n", at3C ? 0x3C : 0x3D);
}

void loop() {
  uint32_t s = millis() / 1000;
  char buf[24];
  oled.clearBuffer();
  oled.setFont(u8g2_font_6x12_tr);
  oled.drawStr(0, 12, "ESP32 DevKit V1");
  oled.drawStr(0, 26, "SH1106 1.3\" OLED");
  oled.setFont(u8g2_font_logisoso22_tn);
  snprintf(buf, sizeof buf, "%02lu:%02lu:%02lu", s / 3600, (s / 60) % 60, s % 60);
  oled.drawStr(0, 60, buf);
  oled.sendBuffer();
  Serial.printf("Uptime %s\n", buf);
  delay(1000);
}

Library: U8g2 (oliver) — compiled with U8g2 2.36.19.

Expected serial output

Serial Monitor · 115200Output
SH1106 at 0x3C
Uptime 00:00:01
Uptime 00:00:02

Common errors

Random pixels down one edge, picture shifted

An SSD1306 driver on an SH1106 panel. Use this U8g2 sketch. Fix guide.

Screen stays black

Power reversed or SDA/SCK swapped. Run the I2C scanner: 0x3C or 0x3D means the wiring is right and only the address or driver is wrong.

Display flickers when Wi-Fi starts

Supply dips on the 3V3 rail. Add a 10 µF capacitor at the OLED and keep the I2C wires short.

↑↓ to move · Enter to open