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 V1 | SH1106 OLED 1.3″ (128×64, I2C) | Wire | Notes |
|---|---|---|---|
| 3V3 | VDD | red | The pull-ups go to VDD; 3V3 keeps SDA/SCK at ESP32 levels. |
| GND | GND | black | Check the order on your module — some put GND first, some VDD. |
| D22 | SCK | yellow | SCK on this module is the I2C clock (SCL). |
| D21 | SDA | blue |
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_NONAMEdriver 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
// 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);
}// 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
SH1106 at 0x3C
Uptime 00:00:01
Uptime 00:00:02SH1106 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.