Source: https://mokxi.com/libraries/liquidcrystal-pcf8574
Updated: 2026-11-11

Libraries / Displays

Arduino library · Displays

# LiquidCrystal_PCF8574: an I2C LCD with the size in begin()

LiquidCrystal_PCF8574 by Matthias Hertel drives the common 16x2 and 20x4 character LCDs that have a PCF8574 I2C backpack soldered on the back. It is one of several libraries for the same module, and the ESP8266 and ESP32 tutorials often pick it because it builds cleanly on every core.

Open the example in the editor See the calls

Built in on Mokxi: #include <LiquidCrystal_PCF8574.h> and it builds, with nothing to install. Free, and no account needed.

## What LiquidCrystal_PCF8574 does

If you know LiquidCrystal_I2C, three things change. The constructor takes only the address, LiquidCrystal_PCF8574 lcd(0x27). The size is given to begin(16, 2) instead. And the backlight is set with setBacklight(255) rather than backlight(). The rest (setCursor, print, clear, createChar, scrolling) is the standard LiquidCrystal set, so moving a sketch between the two takes a minute.

The runnable example first does what the library’s own example does: it calls Wire.beginTransmission(0x27) and prints the result, so you can see on the Serial Monitor whether the backpack answered before anything is written to the screen. An error of 0 means the address is right. In Mokxi the backlight is on or off; values between 1 and 255 all mean on.

Library Manager name | LiquidCrystal_PCF8574

Author | Matthias Hertel

Include | #include <LiquidCrystal_PCF8574.h>

Boards | every board Mokxi compiles for

In the simulator | Simulated: it runs against the part the way it does on the bench.

Parts it drives | Character LCD with I2C backpack

## Install it

It builds on every board Mokxi compiles for.

In Mokxi it is built in: #include <LiquidCrystal_PCF8574.h> and the sketch compiles, with no download, no zip and no Library Manager.

On a real board, install "LiquidCrystal_PCF8574" by Matthias Hertel from the Arduino IDE’s Library Manager (Sketch, Include Library, Manage Libraries), or add LiquidCrystal_PCF8574 to lib_deps in PlatformIO. Mokxi follows the calls of release 2.3.0, so a sketch written here builds there too.

- ESP32-C3
- Arduino Uno
- Arduino Nano
- Arduino Mega 2560
- Arduino Leonardo
- SparkFun Pro Micro
- Arduino Micro
- ESP32-C6
- WCH CH32V003
- ATtiny85
- Raspberry Pi Pico
- Raspberry Pi Pico W
- Seeed XIAO SAMD21
- STM32
- STM32 Nucleo-F411RE
- STM32 Blue Pill
- micro:bit V2
- Arduino Uno R4
- ESP32 DevKit
- ESP32-S3-DevKitC-1
- ESP8266 NodeMCU
- Arduino Pro Mini 3.3 V
- Seeed XIAO ESP32-C3
- ESP32-C3 SuperMini
- Seeed XIAO ESP32-C6
- ESP32-DevKitC V4
- LOLIN32 Lite
- Wemos D1 R32
- Cheap Yellow Display
- TTGO T-Display
- Seeed XIAO ESP32-S3
- Arduino Nano ESP32
- Arduino Nano RP2040 Connect
- Seeed XIAO RP2040
- Waveshare RP2040-Zero
- Arduino Uno R4 WiFi

## The calls you will use

In the order a sketch meets them.

### LiquidCrystal_PCF8574 lcd(0x27)

Makes the LCD at an I2C address. 0x27 is the most common; backpacks with a PCF8574A chip use 0x3F.

### lcd.begin(16, 2)

Starts the LCD with its columns and rows. Use begin(20, 4) for the larger module.

### lcd.setBacklight(255)

Turns the backlight on; 0 turns it off. Without this call the text is there but hard to read.

### lcd.setCursor(0, 1)

Moves the cursor to a column and row, both counted from 0, so (0, 1) is the start of the second line.

### lcd.print("Hello LCD")

Writes text or a number at the cursor. Text past the end of a line does not wrap onto the next one.

### lcd.clear()

Blanks the screen and returns the cursor home. It takes a couple of milliseconds, so avoid it in a fast loop.

### lcd.createChar(0, heart)

Stores a custom 5x8 character in one of eight slots; print it with lcd.write(0).

## Example: An I2C LCD with LiquidCrystal_PCF8574

On the Arduino Uno R3. It runs in the browser exactly as printed.

sketch.ino · Arduino Uno R3

### Wiring

- Arduino Uno R3 A4 to Character LCD with I2C backpack SDA
- Arduino Uno R3 A5 to Character LCD with I2C backpack SCL
- Arduino Uno R3 5V to Character LCD with I2C backpack VCC
- Arduino Uno R3 GND to Character LCD with I2C backpack GND

Open it in the editor, wired and ready to run

## Common errors and how to fix them

### Error: 2 on the Serial Monitor and a blank screen

Nothing acknowledged at 0x27. Check SDA and SCL (A4 and A5 on an Uno), then try 0x3F, or run an I2C scanner to find the real address and put it in the constructor.

### The backlight is on but the screen shows only a row of blocks

begin() never ran or the contrast is wrong. Make sure begin(16, 2) is called before printing, then turn the contrast potentiometer on the backpack until characters appear.

### no matching function for call to LiquidCrystal_PCF8574(int, int, int)

This library takes only the address in its constructor. Remove the columns and rows from the declaration and pass them to begin() instead.

## Questions and answers

### Should I use LiquidCrystal_PCF8574 or LiquidCrystal_I2C?

Either works with the same module. LiquidCrystal_PCF8574 is tidy on ESP boards and sets the size in begin(); LiquidCrystal_I2C sets it in the constructor and has more tutorials.

## Keep going

### Learn

- Arduino LCD I2C 16x2: Wiring, Code, Scrolling Text
- Arduino I2C LCD Not Working: Blank, Blocks, No Text
- I2C Scanner for Arduino and ESP32, and Fixes

### Parts

- Character LCD with I2C backpack

### More displays libraries

- Adafruit SSD1306
- Adafruit GFX Library
- LiquidCrystal I2C
- LiquidCrystal
- LCD_I2C
- hd44780
- TFT_eSPI
- U8g2

Every built-in library · Open the editor

## Try LiquidCrystal_PCF8574 without installing anything

Open the example, change the sketch, and keep your version in a free account.

Start building free

Open the editor
