How to wire a 16×2 LCD with I²C in 5 minutes

Asked 1 week ago Modified 3 days ago Viewed 5 times
How to wire a 16×2 LCD with I²C in 5 minutes

The non-I²C version of the standard 1602 LCD needs 16 wires and a contrast trimmer. The I²C backpack takes it down to 4 wires and gives you contrast control over software. If you're doing anything more than blinking an LED, this is the upgrade to make.

Parts list

  • 1602 character LCD with soldered-on I²C backpack (PCF8574)
  • Arduino UNO (or Nano — same pinout)
  • 4 × jumper wires

Wiring (UNO)

  • LCD VCC → 5V
  • LCD GND → GND
  • LCD SDA → A4 (UNO's I²C data line)
  • LCD SCL → A5 (UNO's I²C clock line)

On a Mega: SDA = 20, SCL = 21. On a Nano: same as UNO.

Step 1 — Install the LiquidCrystal_I2C library by Frank de Brabander from Library Manager.
Step 2 — Find the LCD's I²C address. It's usually 0x27 or 0x3F. Run the I2C Scanner sketch from arduino.cc; it prints any active addresses on the bus.

Step 3 — Minimal sketch

#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup() {
  lcd.init();
  lcd.backlight();
  lcd.setCursor(0, 0);
  lcd.print("Hello, world!");
}
void loop() {}

Troubleshooting

  • Blank screen, only blue backlight → contrast trimmer on the back of the backpack is wrong. Turn the blue potentiometer slowly until characters appear.
  • Random characters → noisy 5V supply, or your jumper wires are too long. Keep SDA/SCL under 30cm or add 4.7kΩ pull-ups to 5V on both lines.
  • 'Garbage' on the second line of a 20×4 display → the constructor argument is wrong; use lcd(addr, 20, 4).