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

Step by step

  1. Drag Raspberry Pi 4B onto the Canvas.
  2. Drag LCD1602 (I2C) onto the Canvas.
  3. Hover over its pins to confirm labels: GND, VCC, SDA, SCL.
  4. 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 CharLCD
lcd = CharLCD(i2c_expander='PCF8574', address=x27, port=1, cols=16, rows=2)
lcd.write_string("Hello ZOLB!")

What “working correctly” looks like

If something’s wrong

More component tutorials are in Learn.