breadboard
docs

Example project · Displays

E-paper desk sign (2.13 inch)

A wide 2.13-inch e-paper sign, drawn by MicroPython on an ESP32-C6. The script turns its text into the panel’s portrait memory, refreshes the screen, and waits until it is ready. The picture stays when the power is removed.

The E-paper desk sign (2.13 inch) circuit as rendered by the simulator

What's on the bench

  • E-Ink 2.13″ 250×122
  • ESP32-C6

How it's wired

  • ESP32-C6 · 3v3→E-Ink 2.13″ 250×122 · vcc
  • ESP32-C6 · gnd→E-Ink 2.13″ 250×122 · gnd
  • ESP32-C6 · g7→E-Ink 2.13″ 250×122 · din
  • ESP32-C6 · g6→E-Ink 2.13″ 250×122 · clk
  • ESP32-C6 · g5→E-Ink 2.13″ 250×122 · cs
  • ESP32-C6 · g1→E-Ink 2.13″ 250×122 · dc
  • ESP32-C6 · g3→E-Ink 2.13″ 250×122 · rst
  • ESP32-C6 · g0→E-Ink 2.13″ 250×122 · busy

The code

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

from machine import Pin, SPI
import framebuf, time
# Hardware SPI (GPSPI2) on the C6 fixed pins: sck=6, mosi=7.
spi = SPI(1, baudrate=20000000)
cs, dc, rst = Pin(5, Pin.OUT, value=1), Pin(1, Pin.OUT), Pin(3, Pin.OUT, value=1)
busy = Pin(0, Pin.IN)
def cmd(c, data=b""):
    cs(0); dc(0); spi.write(bytes([c]))
    if data:
        dc(1); spi.write(data)
    cs(1)
def wait():
    time.sleep_us(50)  # allow the measured 26-40 us BUSY rise
    while busy.value():
        time.sleep_ms(20)
rst(0); time.sleep_ms(10); rst(1); time.sleep_ms(10)
cmd(0x12); wait()  # SW reset

# Draw in the glass orientation, then turn into the controller RAM.
landscape = bytearray(32 * 122)
fb = framebuf.FrameBuffer(landscape, 256, 122, framebuf.MONO_HLSB)
fb.fill(1)
fb.fill_rect(0, 0, 250, 28, 0)
fb.text('E-PAPER 2.13', 12, 10, 1)
fb.rect(6, 36, 238, 80, 0)
fb.text('A little desk sign', 20, 48, 0)
fb.text('250 x 122 pixels', 20, 68, 0)
fb.text('The image stays', 20, 88, 0)
buf = bytearray(b"\xff" * 4000)
for x in range(250):
    for y in range(122):
        if not fb.pixel(x, y):
            rx = 121 - y
            buf[x * 16 + (rx >> 3)] &= ~(0x80 >> (rx & 7))
cmd(0x11, b'\x03')
cmd(0x44, b'\x00\x0f')  # 16 RAM bytes per row; six padding pixels
cmd(0x45, b'\x00\x00\xf9\x00')  # 250 RAM rows
cmd(0x4E, b'\x00'); cmd(0x4F, b'\x00\x00')
cmd(0x24, buf)
cmd(0x22, b'\xF7'); cmd(0x20)
wait()
print('2.13-inch sign ready (busy =', busy.value(), ')')

Related projects