How-to · Beginner · 3 min read
16x2 LCD with I2C
Wiring, Address, Contrast and Code
By Geekobot Learning Team · Updated 24 Oct 2026
On this page
A 16x2 LCD shows two lines of 16 characters using the HD44780 controller. With a PCF8574 I2C backpack it needs only four wires: VCC, GND, SDA and SCL. The backpack's address is usually 0x27 or 0x3F, and its blue trimmer sets contrast. If the screen lights up but shows nothing or a row of blocks, adjust that trimmer first.
Key specs at a glance
- Display
- 16 characters x 2 lines, 5 x 8 dot characters
- Controller
- HD44780 or compatible
- Supply
- 5 V (3.3 V versions exist)
- Parallel mode
- 6 pins in 4-bit mode (RS, E, D4 to D7)
- I2C backpack
- PCF8574, address 0x27 (PCF8574A: 0x3F)
- Custom characters
- 8 user-defined
Wiring a 16x2 LCD with I2C backpack
| Backpack pin | Arduino Uno | ESP32 | Raspberry Pi Pico |
|---|---|---|---|
| GND | GND | GND | GND |
| VCC | 5V | 5V (VIN) | VBUS (5 V) |
| SDA | A4 | GPIO 21 | GP4 |
| SCL | A5 | GPIO 22 | GP5 |
- GND
- Arduino Uno:
- GND
- ESP32:
- GND
- Raspberry Pi Pico:
- GND
- VCC
- Arduino Uno:
- 5V
- ESP32:
- 5V (VIN)
- Raspberry Pi Pico:
- VBUS (5 V)
- SDA
- Arduino Uno:
- A4
- ESP32:
- GPIO 21
- Raspberry Pi Pico:
- GP4
- SCL
- Arduino Uno:
- A5
- ESP32:
- GPIO 22
- Raspberry Pi Pico:
- GP5
Arduino code for an I2C LCD
Install LiquidCrystal I2C (by Frank de Brabander or a maintained fork) from the Library Manager. If the address is unknown, run the I2C scanner first.
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2); // try 0x3F if blank
void setup() {
lcd.init();
lcd.backlight();
lcd.setCursor(0, 0);
lcd.print("Hello, maker!");
lcd.setCursor(0, 1);
lcd.print("Geekobot");
}
void loop() {}Troubleshooting a blank or garbled LCD
| Symptom | Likely cause | Fix |
|---|---|---|
| Backlight on, no text | Contrast set wrong | Turn the blue trimmer on the backpack slowly |
| Top row of solid blocks | Display not initialised | Check address, SDA/SCL wiring and lcd.init() |
| Nothing at all | No power or backlight jumper missing | Check 5 V and the backlight jumper on the backpack |
| Random characters | Loose wires or long leads | Shorten wires, add a common ground |
| Works on Uno, faint on ESP32 | Powered from 3.3 V | Power the LCD from 5 V |
- Backlight on, no text
- Likely cause:
- Contrast set wrong
- Fix:
- Turn the blue trimmer on the backpack slowly
- Top row of solid blocks
- Likely cause:
- Display not initialised
- Fix:
- Check address, SDA/SCL wiring and lcd.init()
- Nothing at all
- Likely cause:
- No power or backlight jumper missing
- Fix:
- Check 5 V and the backlight jumper on the backpack
- Random characters
- Likely cause:
- Loose wires or long leads
- Fix:
- Shorten wires, add a common ground
- Works on Uno, faint on ESP32
- Likely cause:
- Powered from 3.3 V
- Fix:
- Power the LCD from 5 V
Using a 5 V I2C LCD with ESP32 or Pico
The LCD needs 5 V for good contrast. The backpack's pull-up resistors then hold SDA and SCL at 5 V, which is above the ESP32's and Pico's 3.6 V limit. Many people run it this way without trouble, but the safe method is a BSS138 level shifter between the board and the backpack, or removing the backpack's pull-ups so the 3.3 V board's pull-ups set the level.
16x2 LCD vs OLED vs TFT
Choose a 16x2 or 20x4 LCD for large, readable text in bright rooms and on control panels. Choose an SSD1306 OLED for small graphics and battery projects. Choose a TFT for colour and touch interfaces.
Common mistakes to avoid
- Giving up on a blank screen before adjusting the contrast trimmer.
- Using the wrong address; 0x27 and 0x3F are both common.
- Powering the LCD from 3.3 V so the text is faint or invisible.
- Calling lcd.clear() every loop, which makes the display flicker; overwrite text instead.
- Mixing up libraries: several share the name LiquidCrystal_I2C with different init() and begin() calls.
Frequently asked questions
What is the I2C address of a 16x2 LCD?
Usually 0x27 for backpacks with the PCF8574 chip and 0x3F for the PCF8574A. Solder pads A0 to A2 change it. An I2C scanner confirms the address.
Why does my LCD show only boxes?
A row of blocks means the display is powered but not initialised. Check SDA/SCL wiring, the address in your code, and adjust the contrast.
Can I use a 16x2 LCD without I2C?
Yes, in 4-bit parallel mode using six digital pins (RS, E, D4 to D7) and the built-in LiquidCrystal library, plus a 10 kΩ potentiometer for contrast.
Does a 16x2 LCD work with ESP32?
Yes. Power it from 5 V and use GPIO 21 and 22 for I2C. A level shifter is the safest way to handle the backpack's 5 V pull-ups.
How do I show custom symbols on an LCD?
Use lcd.createChar(slot, pattern) with an 8-byte pattern. You can store up to eight custom characters, such as a degree sign or battery icon.
Parts for this guide
Terms in this guide
Projects that use it
Put this into practice: 249 step-by-step builds in our project library use parts from this guide.
Keep learning
Sources
- HD44780U dot-matrix LCD controller datasheet (Hitachi)
- PCF8574 remote 8-bit I/O expander datasheet (NXP / Texas Instruments)
Written by the Geekobot team from manufacturer datasheets. Always check the datasheet for the exact part and variant you buy.



