LCD
Interfacing LCD2004 I2C with Raspberry Pi
What is the LCD2004 I2C?
LCD2004 I2C practical reference
The LCD2004 is a 20-column, 4-row character LCD, built on the same HD44780-family controller as the smaller LCD1602 and almost always sold with the identical PCF8574 I2C backpack. That means the wiring, the library, and the code are essentially the same as the LCD1602 — the only real difference is passing 20, 4 instead of 16, 2 into the constructor. If a project's status screen or menu has outgrown two lines of 16 characters, this is the natural next step up rather than a different technology to learn.
Like the LCD1602, it only displays fixed-width text characters (plus up to 8 custom 5x8 glyphs), not arbitrary graphics — for pixel-level graphics, look at a display like the SSD1306 OLED instead.
Key specifications
- Display: 20 characters × 4 lines, fixed-width text (HD44780-family controller)
- Backpack: PCF8574 I2C I/O expander (converts the LCD's 6-wire parallel interface to I2C)
- Operating voltage: 5 V DC (most common); some 3.3V-tolerant backpacks exist but are less common
- I2C address: 0x27 default on most PCF8574 backpacks, 0x3F on some clones — scan to confirm
- Interface: I2C, up to 100 kHz typical
- Backlight: LED backlight, on/off controllable over I2C
- Custom characters: Up to 8 user-defined 5×8 pixel glyphs
Pinout and connection notes
Identical wiring considerations to the LCD1602: the PCF8574 backpack's I2C pull-ups reference VCC, and the panel needs 5V for proper contrast/brightness, so on 3.3V-only boards you're typically feeding VCC from a 5V rail while accepting 5V-level I2C signaling (or adding a level shifter if you want to be strict). If text looks like solid blocks or is invisible, adjust the contrast potentiometer on the back of the backpack first. If the bus doesn't respond at all, run an I2C scanner sketch to confirm whether the address is 0x27 or 0x3F before touching your code.
- GND: Ground
- VCC: Power, 5V DC
- SDA: I2C data line
- SCL: I2C clock line
Integration checklist
- Confirm the exact part number and breakout-board revision.
- Verify supply voltage, current demand, logic levels, and signal direction against the datasheet.
- Check controller pin assignments and bus address or interface mode against the example code.
- Power up with external loads disconnected, then test signals before full integration.
- If readings or communication fail, check power and ground first, then pin mapping, interface settings, and library initialization.
Troubleshooting and reproducibility
Record the board used, wiring, library/version, supply arrangement, and measured behavior. Use the selected board-specific wiring example as the source of truth. Never assume visually similar modules share identical voltage tolerance or pin order.
Setting Up LCD2004 I2C with Raspberry Pi
Library
RPLCD by Danilo Bargen
sudo raspi-config # Interface Options -> I2C -> Enable, then reboot pip3 install RPLCD smbus2
Wiring
| Component pin | Raspberry Pi pin | Note |
|---|---|---|
| VCC | Pin 2 (5V) | The display needs a real 5V rail for contrast/brightness. |
| GND | Pin 6 (GND) | |
| SDA | GPIO2 (Pin 3) | Pi's dedicated hardware I2C data pin. |
| SCL | GPIO3 (Pin 5) | Pi's dedicated hardware I2C clock pin. |
Swipe sideways to see every column →
- I2C is disabled on Raspberry Pi OS by default - enable it via
raspi-configand reboot before the display will show up. - Run
i2cdetect -y 1to confirm the actual address (0x27 vs 0x3F) before debugging Python code. RPLCD.i2c.CharLCDuses (row, col) tuples forcursor_pos, unlike the Arduino library'ssetCursor(col, row)order — easy to transpose by accident when porting code between boards.
Related Components
Related Guides & Projects
Raspberry Pi Pico W and Pico 2 W: Install MicroPython with Thonny or UF2
Hold BOOTSEL, drag the correct UF2 file, open the REPL and blink the onboard LED. Includes the Pico vs Pico W vs Pico 2 W firmware differences and what to do when the drive does not appear.
Raspberry Pi Pico W Web Server in MicroPython: Control an LED and Read a Sensor
Connect the Pico W to WiFi, serve a responsive control page, switch an LED and display the onboard temperature or an external sensor, with timeouts and reconnect handling.
Raspberry Pi Pico Oscilloscope with MicroPython
Convert a Raspberry Pi Pico into a basic 500 kSPS oscilloscope using its 12-bit ADC and MicroPython. Displays waveforms on an SSD1306 OLED or streams samples over USB serial to a Python plotter on your PC.
Self-Hosted Nextcloud NAS on Raspberry Pi 4
Build a private, durable Nextcloud NAS on a Raspberry Pi 4 -- SSD boot instead of a failure-prone SD card, Docker Compose with Redis caching, Tailscale for remote access with zero ports forwarded, and an automated backup strategy that actually runs.