LCD 20x4 with I2C backpack with ESP32
Supply 5 V
Bus I2C
I2C address
0x20 / 0x21 / 0x22 / 0x23 / 0x24 / 0x25 / 0x26 / 0x27 / 0x38 / 0x39 / 0x3A / 0x3B / 0x3C / 0x3D / 0x3E / 0x3F
Pins and ESP32 wiring
| Pin | Role | ESP32 pin | Notes |
|---|---|---|---|
| GND | Ground | GND | |
| VCC | Power | VIN | Needs 5 V for good contrast: use VIN |
| SDA | I2C data (SDA) | D21 | The backpack pulls SDA up to 5 V. Usually works; a level shifter is safer |
| SCL | I2C clock (SCL) | D22 | The backpack pulls SCL up to 5 V. Usually works; a level shifter is safer |
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)
#include <Wire.h>
void setup() {
Serial.begin(115200);
Wire.begin(21, 22); // SDA = GPIO 21, SCL = GPIO 22
Wire.beginTransmission(0x20);
bool found = Wire.endTransmission() == 0;
Serial.println(found ? "LCD 20x4 with I2C backpack found at 0x20" : "Not found: check power, GND and SDA/SCL");
}
void loop() {}
Sources
- NXP PCF8574 / PCF8574A datasheet, Address 0x20 to 0x27 (PCF8574T) or 0x38 to 0x3F (PCF8574AT) via A0-A2; most backpacks ship as 0x27 or 0x3F
- Hitachi HD44780U datasheet, Supply 5 V for standard character LCDs
Try it in 3D in BoardPilot
Related parts
HT16K33 4-digit 7-segment backpack (I2C)HT16K33 8x8 LED matrix backpack (I2C)LCD 16x2 with I2C backpackSH1106 OLED 1.3" 128x64 (I2C)SSD1306 OLED 0.91" 128x32 (I2C)SSD1306 OLED 128x64 (I2C)
Part data: CC BY 4.0, free to reuse with credit to BoardPilot.