MicroPython ST7305 driver for Waveshare ESP32-S3-RLCD-4.2
MIT-licensed, monochrome framebuf driver for the 400 × 300 reflective LCD
on the Waveshare ESP32-S3-RLCD-4.2↗ (opens in a new tab).
This targets the board's 4.2-inch panel, not other ST7305 display sizes.
Based on elulis's MIT-licensed ST7305 MicroPython driver↗ (opens in a new tab). The panel-specific init values, 400 × 300 address window and landscape pixel layout follow Waveshare's display example↗ (opens in a new tab). No code from GPL-licensed drivers is used.
Install
With the board running MicroPython and connected over USB:
mpremote connect /dev/ttyACM0 mip install github:mattytrentini/MicroPython_ST7305_RLCD
Alternatively, copy st7305_rlcd.py to the board with mpremote fs cp.
No additional Python dependencies are needed; firmware must support framebuf
and MicroPython's @micropython.viper emitter.
Usage
from machine import Pin, SPI
from st7305_rlcd import RLCD42
# SPI(1) defaults to this display's SCK=11 and MOSI=12 on the
# WAVESHARE_ESP32_S3_RLCD_42 MicroPython board build. MISO is not wired.
spi = SPI(1, baudrate=10_000_000, polarity=0, phase=0)
lcd = RLCD42(spi, Pin(40, Pin.OUT), Pin(5, Pin.OUT), Pin(41, Pin.OUT))
lcd.fill(0) # Black background
lcd.text("Hello, RLCD!", 20, 20, 1) # White text
lcd.rect(1, 1, 398, 298, 1) # White border, 1-pixel edge gap
lcd.refresh() # Send the full image over SPI
The screen is 400 pixels wide by 300 pixels high in landscape orientation.
RLCD42 inherits framebuf.FrameBuffer: pixel, line, rect, fill_rect,
text, and blit update an in-memory canvas; refresh() transfers it. Color
0 is black and 1 is white on this board. The driver uses 15,200 bytes for
the padded MONO_VLSB canvas and 15,000 bytes for the panel-format transfer
buffer. The board's TE pin (GPIO6) is not required for full-screen refreshes.
The SPI(1) pin defaults above are specific to the
WAVESHARE_ESP32_S3_RLCD_42 MicroPython board build. On other MicroPython
firmware, pass sck=Pin(11), mosi=Pin(12) explicitly and select a suitable
hardware SPI bus with no MISO.
Attribution and license
Copyright © 2024 Eluli; modifications © 2026 Matty Trentini. Released under the MIT license↗ (opens in a new tab). Waveshare's example repository↗ (opens in a new tab) provides the board-specific electrical settings and pixel format reference.