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.
Note: the LCD1602 (I2C) is a Premium-tier component in the simulator — you’ll need a Premium or VIP plan to use it there.
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!")- Click Start. The display only works while the simulation is running.
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.
- Nothing appears and the script runs without an error → this display always answers at I2C address 0x27, and it has no address setting. Use address=0x27 in your script.
- The display stays blank → check its power. GND must reach a Pi GND pin and VCC must reach a Pi power pin, and the simulation must be running. An unpowered display ignores your script.
- You left SDA or SCL unwired and the text still appears → the simulator does not check those two wires. Wire them anyway, because a real display needs them.
- The text is gone after a restart → each Start begins with a clean, blank display. Your script has to write the text again.