Breadboard
docs
Example project · Displays & sensors

SH1106 1.3″ OLED hello

The 1.3" SH1106 OLED (the bigger cousin of the SSD1306) showing live text. Demonstrates a correct SH1106 driver: page addressing with the classic 2-column RAM offset.

The SH1106 1.3″ OLED hello circuit as rendered by the simulator

What's on the bench

  • Battery
  • ESP32-C3
  • OLED 1.3″

The code

This MicroPython script runs on the emulated board every boot; edit it in the Code tab.

from machine import Pin, I2C
import framebuf, time
i = I2C(0, scl=Pin(9), sda=Pin(8))
for c in (0xAE,0xD5,0x80,0xA8,0x3F,0xAD,0x8B,0xA1,0xC8,0x81,0xCF,0xA6,0xAF):
    i.writeto(0x3c, bytes([0x00, c]))
buf = bytearray(1024)
fb = framebuf.FrameBuffer(buf, 128, 64, framebuf.MONO_VLSB)
def show():
    for page in range(8):
        i.writeto(0x3c, bytes([0x00, 0xB0 | page, 0x02, 0x10]))
        i.writeto(0x3c, bytes([0x40]) + buf[page * 128:(page + 1) * 128])

n = 0
while True:
    fb.fill(0)
    fb.text('SH1106 1.3in', 12, 6)
    fb.text('hello, world!', 12, 26)
    fb.text('frame %d' % n, 24, 46)
    show()
    print('frame', n)
    n += 1
    time.sleep_ms(400)