ESP8266 or ESP32 I2C LCD display Interface

In IoT, LCD is rarely required, but some times its useful to monitor errors and connection related issues. In this tutorial we are interfacing I2C LCD with ESP8266 or ESP32. Both code examples are given.

We have very few IOs on ESP8266 and ESP32. I2C based display interface uses only two IO lines.

ESP8266 I2C LCD Interface
ESP8266 and ESP32 I2C LCD Interface

ESP8266 (NodeMCU) I2C LCD Interface

Parts Required

  1. I2C LCD Display Module PCF8574
  2. 16×2 LCD Display
  3. Connection Wires
  4. Single row female connector
  5. NodeMCU

Step 1: Installing I2C LCD Library for ESP8266 and ESP32

This library is tested for different types of LCD displays like 16×2, 16×4, 20×2, 20×4 with both ESP32 and ESP8266, it also works with other ESP modules.

ESP8266 with 20×4 i2c, 1602 LCD adaptable to others, tested with ESP-201 and ESP-01 Compatible with the Arduino IDE 1.6.6 Library

Step 1: Download Library


Step 2: Install it in Arduino IDE

Click on Sketch >> Include Library >> Add .ZIP Library

Then give your downloaded zip file path.

ESP8266 I2C LCD Library
Library ZIP File adding to IDE

Step 2: Interface ESP8266 With I2C LCD Module

I2C LCD Module Pinout

You can adjust contrast using Blue color potentiometer. LCD default address is 0x27.

I2C LCD Module Pinout
I2C LCD Module Pinout

I2C LCD Module              ESP8266
GND   <——————-> GND
VCC    <——————-> Vin
SDA   <——————-> D2 (NodeMCU) GPIO 4
SCL   <——————-> D1 (NodeMCU) GPIO 5

I2C LCD Display Module
ESP8266 Connections

Step 3: Arduino IDE Code for ESP8266 I2C LCD Interfacing

This is simple code to display text, cursor and scrolling text. Upload this code it will demonstrate many functions of library such as scrolling, display on off, cursor positioning


After uploading you will see some text on LCD. for arduino I2C LCD Interface see this example.

ESP32 I2C LCD Interfacing

Same code and Library works for ESP32. only difference is of connections.

Step 1: Download Library I2C-LCD-ESP8266-Library

Step 2: Make connections with ESP32

I2C LCD Module              ESP8266
GND   <——————-> GND
VCC    <——————-> Vin
SDA   <——————-> GPIO 21
SCL   <——————->  GPIO 22

ESP32 I2C LCD Interfacing
ESP32 I2C LCD Interfacing

Step 3: ESP32 Arduino IDE Code for I2C LCD

Upload code


Upload code and see LCD display is working. If you are looking for low cost solution you can use below referances

  1. 3-Wire LCD interface without I2C Module with Arduino
  2. NodeMCU 3-Wire LCD Interfacing
  3. OLED Display Interfacing with ESP32
  4. NodeMCU OLED Display Example

More on I2C

I2C is a serial protocol for two-wire interface to connect low-speed devices like microcontrollers, EEPROMs, A/D and D/A converters, I/O interfaces and other similar peripherals in embedded systems. It was invented by Philips and now it is used by almost all major IC manufacturers.

I2C LCD Module

It is based on PCF8574 I2C IO expander, Datasheet PCF8574.


Leave a Reply