How to connect an LCD1602 to Arduino over I2C

Four wires, address 0x27 or 0x3F and contrast.

Wiring diagram

Open in the builder

Connections

StepFromToColor
1Arduino Uno GNDLCD1602 I2C GNDblack
2Arduino Uno 5VLCD1602 I2C VCCred
3Arduino Uno A4LCD1602 I2C SDAI2C, green
4Arduino Uno A5LCD1602 I2C SCLI2C, green

Power and wiring check

  • The schematic check, the same as in the builder, found no errors: pin voltages match, ground is common, buses are fully connected.
  • LCD1602 I2C draws up to 40 mA (about 30 typically) from the 5V pin of Arduino Uno, the pin supplies about 400 mA: USB gives 500 mA, the board takes part of it.

Current of the whole circuit and how long it runs on a battery: power budget. Where to plug what: breadboard layout.

Example code

Arduino IDE, LiquidCrystal_I2C (Frank de Brabander) 1.1.2.

#include <Wire.h>
#include <LiquidCrystal_I2C.h>

// 0x27 on a PCF8574T backpack, 0x3F on a PCF8574AT
LiquidCrystal_I2C lcd(0x27, 16, 2);

void setup() {
  lcd.init();
  lcd.backlight();
  lcd.setCursor(0, 0);
  lcd.print("Hello, olerast");
}

void loop() {
  lcd.setCursor(0, 1);
  lcd.print(millis() / 1000);
}

Part pinouts

Next steps for this circuit

How it is connected

The PCF8574 adapter turns the 16 pins of an LCD1602 into four: GND, VCC, SDA and SCL. On an Arduino Uno the I2C bus is on A4 (SDA) and A5 (SCL), and the same lines are brought out to the SDA and SCL pins next to AREF. Power is 5 V: at 3.3 V the characters are barely visible.

The adapter has 4.7 kΩ pull-ups to VCC, so you don't need resistors on SDA and SCL. The backlight draws 20-30 mA, the whole module up to 40 mA, and the Uno's 5V pin gives about 400 mA when powered from USB.

Common mistakes

  • After uploading the sketch the screen lights up but there is no text. Turn the blue trimmer on the adapter: it is the contrast, and from the factory it is often turned all the way to one end.
  • The sketch uses address 0x27, but the adapter has a PCF8574AT at 0x3F. The screen stays blank with no error. The board tester or the I2C address table will show the address.

FAQ

Can I connect an LCD1602 I2C to an ESP32?
You can, but the adapter's pull-ups pull SDA and SCL up to 5 V, while the ESP32 pins are rated for 3.3 V. Use a level shifter, or desolder the pull-ups and fit 4.7 kΩ to 3.3 V. The builder flags such a circuit as an error.
Why does the screen show only rectangles?
Rectangles in the top row mean the screen is on but has received no commands. Check the address in the sketch, the SDA and SCL wires and the lcd.init() call in setup.

You might also need