LCD 128x64 ST7920 (serial mode) with ESP32
Supply 5 V
Bus SPI
Pins and ESP32 wiring
| Pin | Role | ESP32 pin | Notes |
|---|---|---|---|
| GND | Ground | GND | |
| VCC | Power | VIN | 5 V: use VIN |
| V0 | Not wired to the ESP32 | — | Contrast. Many boards have a trimmer on the back instead |
| RS | SPI chip select | D5 | Serial mode: chip select (CS), active HIGH |
| R/W | SPI MOSI | D23 | Serial mode: data in (SID). A level shifter to 5 V makes it reliable |
| E | SPI clock | D18 | Serial mode: clock (SCLK) |
| DB0 | Not wired to the ESP32 | — | Parallel mode only |
| DB1 | Not wired to the ESP32 | — | Parallel mode only |
| DB2 | Not wired to the ESP32 | — | Parallel mode only |
| DB3 | Not wired to the ESP32 | — | Parallel mode only |
| DB4 | Not wired to the ESP32 | — | Parallel mode only |
| DB5 | Not wired to the ESP32 | — | Parallel mode only |
| DB6 | Not wired to the ESP32 | — | Parallel mode only |
| DB7 | Not wired to the ESP32 | — | Parallel mode only |
| PSB | Ground | GND | LOW selects serial mode: connect to GND |
| NC | Not wired to the ESP32 | — | Not connected |
| RST | Input (the ESP32 drives it) | D25 | Reset, active LOW. Can also be tied HIGH |
| VOUT | Not wired to the ESP32 | — | Contrast voltage output. Leave unconnected |
| BLA | Not wired to the ESP32 | — | Backlight anode: to 5 V |
| BLK | Not wired to the ESP32 | — | Backlight cathode: to GND |
Suggested wiring for the 30-pin ESP32 DevKit, avoiding flash, input-only and strapping pins. BoardPilot checks it for you as you wire.
This module is sold for 5 V. Its outputs may be 5 V: use a level shifter or a voltage divider on ESP32 inputs.
Starter code (Arduino)
void setup() { pinMode(25, OUTPUT); } // RST
void loop() {
digitalWrite(25, HIGH);
delay(500);
digitalWrite(25, LOW);
delay(500);
}
Sources
- Sitronix ST7920 datasheet, Serial interface: CS (RS), SID (R/W), SCLK (E); PSB LOW selects serial
Try it in 3D in BoardPilot
Related parts
APA102 / SK9822 LED strip (clock + data)E-paper 1.54" 200x200 (SPI)E-paper 2.13" 250x122 (SPI)E-paper 2.9" 296x128 (SPI)E-paper 4.2" 400x300 (SPI)GC9A01 1.28" round IPS 240x240 (SPI)
Part data: CC BY 4.0, free to reuse with credit to BoardPilot.