A 16×2 or 20×4 character LCD with an I2C backpack needs only four wires instead of twelve. The backpack is a small board with a PCF8574 I/O expander soldered to the back of the display. This guide covers the wiring, the 0x27 address, the right library and the fixes for the most common problems.
Wiring
| LCD backpack | Uno / Nano | Mega 2560 | ESP32 (default) |
|---|---|---|---|
| GND | GND | GND | GND |
| VCC | 5V | 5V | 5V (VIN) * |
| SDA | A4 | 20 | GPIO 21 |
| SCL | A5 | 21 | GPIO 22 |
* Most character LCDs need 5 V for good contrast. With a 3.3 V board such as the ESP32 it usually works, but a level shifter on SDA and SCL is the safe choice.
SANEC Arduino 2×16 LCD Display (with I2C Module)
Arduino product listed on Amazon.com.tr. Check current price, specifications and availability on Amazon before purchasing.
IIC / I2C Serial LCD Adapter Module for 1602, 1604, 2004 Character LCDs, Arduino
Arduino product listed on Amazon.com.tr. Check current price, specifications and availability on Amazon before purchasing.
Find the I2C address (0x27 or 0x3F)
Backpacks with a PCF8574T chip usually use address 0x27; those with a PCF8574AT use 0x3F. Do not guess — upload this I2C scanner and open the Serial Monitor at 9600 baud:
#include <Wire.h>
void setup() {
Wire.begin();
Serial.begin(9600);
for (byte address = 1; address < 127; address++) {
Wire.beginTransmission(address);
if (Wire.endTransmission() == 0) {
Serial.print("I2C device found at 0x");
Serial.println(address, HEX);
}
}
}
void loop() {}
Example code with LiquidCrystal_I2C
Install LiquidCrystal I2C by Frank de Brabander from the Library Manager, then:
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2); // address, columns, rows
void setup() {
lcd.init();
lcd.backlight();
lcd.setCursor(0, 0);
lcd.print("Hello, maker!");
lcd.setCursor(0, 1);
lcd.print("Arduino Forum");
}
void loop() {}
What does “0x27, 2, 1, 0, 4, 5, 6, 7” mean?
You will see older examples written as LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);. That constructor belongs to a different library, NewLiquidCrystal by F. Malpartida. The numbers tell it which PCF8574 pins are wired to the LCD: Enable = 2, RW = 1, RS = 0, D4–D7 = 4–7 and the backlight on pin 3 (POSITIVE = backlight on when the pin is HIGH). If you use the Frank de Brabander library, use the short form (0x27, 16, 2) instead. Do not install both libraries at the same time — they use the same header name and cause confusing compile errors.
Troubleshooting
- Backlight on but no text, or a row of boxes: turn the blue contrast potentiometer on the backpack slowly with a small screwdriver. This fixes most “blank screen” problems.
- Nothing found by the scanner: check SDA and SCL are not swapped, GND is shared, and the jumper wires are firmly connected.
- No backlight: make sure the backlight jumper on the backpack is fitted and call
lcd.backlight(). - Strange characters: the address or library constructor does not match your backpack, or the wires are too long.
- Compile error “LiquidCrystal_I2C does not name a type”: the library is not installed, or two LCD libraries conflict.
Still stuck? Post your board, backpack chip, scanner output and code in the Sensors & Modules board.



Comments
No comments yet. Questions about this guide, or tried it yourself? Share it below.