16x2 I2C LCD: pinout and wiring
The 16x2 LCD with an I2C adapter shows 2 lines of 16 characters using only 4 wires. See the pinout, how to find the address (0x27 or 0x3F), the contrast adjustment, the code and try it in the simulator.
Specifications
- Display
- 16 columns × 2 rows, HD44780 controller
- Supply
- 5 V
- Interface
- I2C (SDA and SCL) through the PCF8574 adapter
- Address
- 0x27 (PCF8574) or 0x3F (PCF8574A)
- Address range
- 0x20 to 0x27 (PCF8574) or 0x38 to 0x3F (PCF8574A)
- Consumption
- ≈ 20 mA with the backlight
- Characters
- 5 × 8 pixels, 8 user-definable
- Backlight
- Blue or green, switched by a jumper on the adapter
Pinout
The I2C adapter has four connection pins on the connector side. Contrast is set with the blue trimpot on the back.
I2C adapter (4 pins)
| 1 | GND | Ground |
| 2 | VCC | Supply, 5 V |
| 3 | SDA | I2C data |
| 4 | SCL | I2C clock |
16x2 I2C LCD simulator
Set the chip and jumpers to see the I2C address, and type some text to see how it looks on the display.
A closed jumper pulls that address bit to 0. With none closed, the address is the highest in the range.
The PCF8574 uses addresses 0x20 to 0x27 and the PCF8574A 0x38 to 0x3F. Each closed jumper A0 to A2 pulls one address bit to zero.
How to wire it
On the Arduino Uno connect GND to ground, VCC to 5 V, SDA to A4 and SCL to A5. On the Mega, SDA is D20 and SCL is D21. On the ESP32 use GPIO 21 (SDA) and GPIO 22 (SCL).
The address depends on the adapter chip: 0x27 for the PCF8574 and 0x3F for the PCF8574A. Jumpers A0, A1 and A2 on the board change the address. If in doubt, run an I2C scanner sketch to find it.
If the screen lights but shows only a row of boxes, adjust the contrast with the blue trimpot behind the adapter, turning it with a small screwdriver.
Use the LiquidCrystal_I2C library: lcd.init() and lcd.backlight() start the display, lcd.setCursor(column, row) picks the position and lcd.print() writes the text.
If the screen does not light, check the address and the 5 V supply. The adapter works at 5 V; at 3.3 V the image is faint.
Example code (Arduino)
Sketch that shows two lines of text on the 16x2 LCD at address 0x27.
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2); // use 0x3F if needed
void setup() {
lcd.init();
lcd.backlight();
lcd.setCursor(0, 0);
lcd.print("Hello, 4DVolt!");
lcd.setCursor(0, 1);
lcd.print("Temp: 25.3 C");
}
void loop() {
}
Common mistakes
- Using the wrong address: the screen lights but stays blank. Run the I2C scanner to find 0x27 or 0x3F.
- Not adjusting contrast: with the trimpot at the end of its range the text vanishes or shows a bar of boxes.
- Swapping SDA and SCL: nothing appears and the scanner finds no device.
- Writing more than 16 characters per line: the text wraps to the other line or is lost.
- Forgetting lcd.clear() when updating values: old characters are left on the line.
Always check the manufacturer's datasheet for your exact model: pin order can vary between modules.
Frequently asked questions
How do I find the LCD I2C address?
Upload an I2C scanner sketch, which walks the addresses and prints those that respond. Usually it shows 0x27 or 0x3F.
Which pins does the I2C LCD use on Arduino Uno?
SDA on A4 and SCL on A5, plus VCC and GND. That is only four wires, against more than ten on an LCD without the adapter.
Why does the I2C LCD light up but show no text?
Almost always the contrast is badly set on the blue trimpot, or the I2C address is wrong in the code.
Does the 16x2 I2C LCD work with ESP32?
Yes. Use GPIO 21 (SDA) and 22 (SCL) and power the module from 5 V. Many work with 3.3 V signals.