SH1107 OLED 128×128 with an ESP32 DevKit V1

A 1.5-inch square monochrome OLED module built on the SH1107 controller, driving a self-lit 128x128 pixel grid over I2C.

SH1107 OLED 128×128, A 1.5-inch square monochrome OLED module built on the SH1107 controller, driving a self-lit 128x128 pixel grid over I2C.
In short

The SH1107 128x128 OLED runs from the ESP32 DevKit V1's 3V3 through its own regulator and talks I2C on GPIO21 (SDA) and GPIO22 (SCL) at address 0x3C. The page's U8g2 sketch uses the page-buffer constructor, the one that also fits an Uno; on the ESP32 the full-buffer version is an easy upgrade.

Wiring the SH1107 OLED 128×128 to the ESP32 DevKit V1

Pin by pin.

SH1107 OLED 128×128ESP32 DevKit V1
VCC3V3
GNDGND
SCLGPIO22 (D22)
SDAGPIO21 (D21)

What to know on the ESP32 DevKit V1

  • The ESP32 has 520 KB of SRAM, so U8G2_SH1107_128X128_F_HW_I2C, which keeps the whole 128 x 128 frame (2 KB) in memory, fits easily and draws each frame in one pass instead of the _1_ constructor's repeated page loop.Espressif ESP32 Series Datasheet v5.3, p. 4
  • The controller runs fast-mode I2C at up to 400 kHz, which the ESP32's I2C controllers support: call Wire.setClock(400000) or u8g2.setBusClock(400000) for quicker refreshes.Sino Wealth SH1107 datasheet V2.1; Espressif ESP32 Series Datasheet v5.3, p. 37
  • Only one 0x3C device fits on a bus. If the project also has an SSD1306 at 0x3C, move one of them to the ESP32's second I2C controller on two other GPIOs.Espressif ESP32 Series Datasheet v5.3, p. 4

SH1107 OLED 128×128 code for the ESP32 DevKit V1

Compiled for esp32:esp32:esp32 on 2026-10-30.

Libraries: olikraus/U8g2
// SH1107 OLED 128×128 on ESP32 DevKit V1: wiring and a free simulation at https://www.tinkered.ai/components/oled-sh1107-128x128/esp32
#include <Arduino.h>
#include <U8g2lib.h>
#include <Wire.h>

// SH1107 128x128, PAGE-BUFFER mode ("_1_", a 128 B page buffer) so it fits an Uno.
U8G2_SH1107_128X128_1_HW_I2C u8g2(U8G2_R0, U8X8_PIN_NONE);

void setup() {
  Serial.begin(9600);
  u8g2.setI2CAddress(0x3C * 2);   // 8-bit address (0x3C << 1)
  u8g2.begin();
  Serial.println(F("SH1107 U8g2 ready"));
}

void loop() {
  u8g2.firstPage();
  do {
    u8g2.drawFrame(0, 0, 128, 128);           // border
    u8g2.setFont(u8g2_font_ncenB10_tr);
    u8g2.drawStr(14, 26, "SH1107");
    u8g2.setFont(u8g2_font_6x12_tr);
    u8g2.drawStr(12, 52, "128x128 OLED");
    u8g2.drawStr(12, 70, "I2C @ 0x3C");
    u8g2.drawDisc(64, 100, 18);               // filled circle
  } while (u8g2.nextPage());
  delay(1000);
}

SH1107 OLED 128×128 on the ESP32 DevKit V1: questions

Which U8g2 constructor should I use for the SH1107 on an ESP32?

U8G2_SH1107_128X128_F_HW_I2C (full buffer) suits the ESP32's 520 KB of SRAM (ESP32 datasheet, p. 4); the page's _1_ page-buffer version also works. Never an SSD1306 constructor or Adafruit_SH110X.

Does the SH1107 OLED need 5 V on the ESP32?

No. The module takes 3.3 V or 5 V through its regulator; with VCC on 3V3 its pull-ups keep SDA and SCL at the ESP32's 3.3 V.

Keep going

For AI assistants

This guide as plain Markdown. /components/oled-sh1107-128x128/esp32.md

What will you build with it?