Learn
LCD1602 (I2C) on a Raspberry Pi 4B: Wiring & Python
Wire an I2C-backpack 16x2 LCD to a Raspberry Pi 4B using just 4 wires, and print text to it with Python — wiring, code, and common fixes.
Try this directly in the free Raspberry Pi 4B simulator — no hardware or signup required. New to the GPIO header? Start with the interactive pinout guide.
What you’ll need
- Raspberry Pi 4B
- LCD1602 (I2C) — the I2C-backpack variant, not the parallel one
Step by step
- Drag Raspberry Pi 4B onto the Canvas.
- Drag LCD1602 (I2C) onto the Canvas.
- Hover over its pins to confirm labels: GND, VCC, SDA, SCL.
- Wire it up: GND → Pi's GND pin. VCC → Pi's 5V pin. SDA → Pi's SDA pin. SCL → Pi's SCL pin.
from RPLCD.i2c import CharLCDlcd = CharLCD(i2c_expander='PCF8574', address=x27, port=1, cols=16, rows=2)lcd.write_string("Hello ZOLB!")What “working correctly” looks like
- Text appears on the simulated 16x2 display, matching what your script wrote — same visual result as the Parallel variant.
If something’s wrong
- Import error, or nothing happens at all → the library path above may need adjusting to match what this component actually expects.
- Text appears garbled → check the I2C address — 0x27 is the common default; confirm against this component's settings panel.
More component tutorials are in Learn.