Character LCD with I2C backpack
The same two rows on four wires, through the PCF8574 backpack at 0x27. Mind the backlight bit.
- 4 pins
- 2 settings
- In 51 projects
- In 17 lessons
The Character LCD with I2C backpack in brief
What it is, and every setting the properties panel gives it.
This is the 16x2 character LCD with a PCF8574 backpack on the back, which turns sixteen pins into four: SDA, SCL, power and ground. The display itself is the same HD44780 controller as the plain module, with its character shapes in ROM, so a sketch sends characters rather than pixels. The backpack is an eight-bit port expander wired to the controller’s control lines, four data lines and the backlight, and every byte the board sends appears on those pins. That has one famous consequence, modeled here: the backlight is a single bit in that byte, and a driver that forgets it gets a display that works and cannot be read. The address is 0x27 by default and is a property, since some backpacks answer at 0x3F. The LiquidCrystal_I2C calls tutorials use compile on every board, and on an Uno they use A4 and A5.
- Family
- Displays
- Pins
- 4
- address
- 39
- contrast
- 0.75
4 pins
Named as the editor names them, so a wire lands where you expect it.
- GND
- VCC
- SDA
- SCL
How to use an I2C LCD with an Arduino
SDA to A4, SCL to A5, VCC to 5 V, GND to GND. Create a LiquidCrystal_I2C with the address and the size, call init() and backlight() in setup(), and print. If the screen stays empty, the address is the first suspect: most backpacks answer at 0x27 and some at 0x3F.
To update a number without flicker, overwrite the line and pad it with spaces rather than calling clear() every time.
LiquidCrystal_I2C compiles on every board here, on whichever pins Wire.begin() uses on that board.
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup() {
lcd.init();
lcd.backlight();
lcd.print("Hello, world!");
}
void loop() {}What is true about the Character LCD with I2C backpack, here
In its help article’s own words: what the simulation gets right, and where it stops.
Not modeled
Reads of any kind. The busy flag, the address counter and DDRAM read back nothing, so a driver that polls the busy flag instead of waiting will hang. Wait instead; that is what every real library does anyway. Also not modeled: the 5x10 font a one-line module can select, and the viewing angle.
The busy timings are the datasheet's two typical numbers (37 microseconds for a write
and 1.52 milliseconds for clear and home), used as exact values. A real HD44780's
timing scales with whatever its internal oscillator happens to be running at, so those
figures move by tens of percent between parts and with temperature, and the 4-bit
nibble timing (the minimum E pulse width and the hold after it) is not checked here
at all: a driver can clock E as fast as it likes.
A byte arriving while the controller is busy is dropped. That is a choice the model makes so the fault is visible and repeatable; on a real part the outcome is undefined and more often a corrupted character than a lost one.
On the backpack, the PCF8574 never stretches the clock and acknowledges every byte
sent to it. There is no read of the expander's port, no NACK and no bus error of any
kind, and the backlight transistor is bit 3 and nothing else: no current, no
brightness. Contrast on the backpack is the contrast property (0 to 1, 0.75 by
default) rather than the trimmer's actual
divider.
See it: Thermometer on an I2C LCD for the backpack, and Thermometer in the templates for the six-wire hookup.
If an I2C LCD stays blank, shows blocks or prints leftovers, Arduino I2C LCD not working goes through the causes by symptom.
From The 16x2 character LCD, in full.
See the Character LCD with I2C backpack in a project
51 built-in projects use it. Each opens in the editor, already wired.
Where it turns up in a lesson
17 lessons place it in their own circuits.
Learn articles
17 lessons
- Arduino LCD I2C 16x2: Wiring, Code, Scrolling Text
- Arduino DHT22 and DHT11: Temperature and Humidity
- I2C Explained: Addresses, Acknowledges and Pull-Ups
- I2C Scanner for Arduino and ESP32, and Fixes
- Arduino I2C LCD Not Working: Blank, Blocks, No Text
- Arduino Battery Level Indicator: 18650 on A0
- Arduino Water Flow Sensor (YF-S201): Code and Wiring
- Arduino Hall Effect Sensor (49E): Wiring and Code
- Arduino MLX90614: Non-Contact IR Thermometer
- Arduino ACS712 Current Sensor: Wiring and Code
- Arduino 0-25 V Voltage Sensor: Wiring and Code
- Arduino FC-28 Soil Moisture Sensor: Wiring and Code
- Arduino Touch Sensor (TTP223): Wiring and Code
- Arduino "Has No Member Named": Causes and Fixes
- Arduino "cannot convert 'String' to 'const char*'"
- Arduino "call of overloaded is ambiguous": Fixes
- Wokwi vs Tinkercad: Which Arduino Simulator to Use
The boards it is shown on
Each of these 2 boards has a built-in project with the Character LCD with I2C backpack in it.
The Character LCD with I2C backpack on each board
The pins, the voltage and the code change from board to board. Each page has that board’s wiring and a circuit you can run.
Arduino libraries for the Character LCD with I2C backpack
Built in, so the sketch compiles with nothing to install. Each page has the calls, the wiring and an example to run.
The rest of the bench
Every one of these is drawn and simulated the same way.
Wire up the Character LCD with I2C backpack
Open the editor and push it into the breadboard. It is free, and it runs on your own machine.