i2c LCD on Arduino: wiring, address & code
A character LCD needs a dozen data pins — unless it has an i2c backpack, which drops it to two. Here's the whole path: wire it, find its address, print text, and fix the blank-screen that stops most people.
Step 1 · Wiring
i2c LCD wiring: four wires instead of sixteen
A bare 1602 (16×2) or 2004 (20×4) LCD uses the HD44780 controller and needs ~12 pins. The little PCF8574 board soldered to the back — the "i2c backpack" — converts that to four: GND, VCC, SDA, SCL. Power VCC from 5 V (the LCD glass needs it), then on an Uno or Nano wire SDA to A4 and SCL to A5:
Worth knowing: that backpack is just a general-purpose i2c GPIO expander wired to the LCD's pins. The same chip — or the roomier MCP23017 — gives you 8 or 16 free pins for buttons and LEDs on any project.
LCD backpack Arduino Uno/Nano
GND ----> GND
VCC ----> 5V
SDA ----> A4
SCL ----> A5 ESP32? Default SDA/SCL are GPIO21/22 — see the voltage note in the FAQ.
Step 2 · Address
Find the i2c address (0x27 or 0x3F)
Backpacks come at one of two addresses depending on the chip: 0x27 for the PCF8574, 0x3F for the PCF8574A. Don't guess — run a scanner and read it off:
#include <Wire.h>
void setup(){ Wire.begin(); Serial.begin(115200);
for(byte a=8;a<120;a++){ Wire.beginTransmission(a);
if(!Wire.endTransmission()){ Serial.print("found 0x"); Serial.println(a,HEX); } } }
void loop(){} Whatever it prints is what you pass to the library next. (Both addresses are in our address list, and yes — 0x3F is the same PCF8574A address that can clash with other parts.)
Step 3 · Code
LiquidCrystal_I2C Arduino code: hello world
Install LiquidCrystal_I2C from the Library Manager, then:
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2); // address, columns, rows
void setup() {
lcd.init(); // start the LCD
lcd.backlight(); // turn the backlight on
lcd.setCursor(0, 0); // column 0, row 0
lcd.print("Hello, I2C!");
lcd.setCursor(0, 1);
lcd.print("i2c.net");
}
void loop() {} Change 0x27 to whatever the scanner found, and 16, 2 to 20, 4 for a 2004 display. That's a complete working sketch.
Step 4 · The fix nobody mentions
i2c LCD blank screen? Turn the contrast pot
By far the most common "my i2c LCD doesn't work" is a display that's powered, scanning at the right address, running correct code — and showing nothing, or a row of solid blocks. The cause is contrast. There's a small blue potentiometer on the backpack; turn it slowly with a screwdriver and the characters fade into view. If the scan finds nothing at all instead, it's wiring or power — work the troubleshooting checklist, and confirm VCC is 5 V.
Get one
Questions
i2c LCD FAQ
What is the i2c address of a 1602 LCD?
Almost always 0x27 for the common PCF8574-based backpack, or 0x3F if the backpack uses the PCF8574A variant. A few clones sit elsewhere — run a scanner sketch to be sure, then pass that address to LiquidCrystal_I2C.
Why is my i2c LCD backlight on but showing no text?
Two usual causes. First, contrast — turn the blue trimpot on the backpack until characters appear. Second, a wrong address or a missing lcd.init()/lcd.backlight() call. If a scanner finds nothing at all, check wiring and that the backpack is getting 5 V, not 3.3 V.
Which library should I use for an i2c LCD?
LiquidCrystal_I2C is the de-facto standard for PCF8574 backpacks — the constructor takes the address, columns and rows, e.g. LiquidCrystal_I2C lcd(0x27, 16, 2). Several forks exist with the same API; the Frank de Brabander version is the most widely used.
Can I run an i2c LCD at 3.3 V on an ESP32?
The LCD glass and its HD44780 controller want 5 V for a readable display, but the PCF8574's i2c lines are fine at 3.3 V logic. The common fix on a 3.3 V board like the ESP32 is to power the backpack VCC from 5 V while its SDA/SCL sit at 3.3 V — most backpacks tolerate this. Check the module, or use a level shifter to be safe.
How do I connect two i2c LCDs at once?
Change one backpack's address so they don't collide. The three solder jumpers (A0/A1/A2) on the PCF8574 backpack set the low address bits, giving a range of 0x20–0x27 (or 0x38–0x3F for the A variant). Bridge them differently on each display, or use a multiplexer.