Back to Tutorial

ESP32 + I2C LCD for Real-Time Feedback


📘 What is an I2C LCD?

An I2C LCD is a Liquid Crystal Display that uses the I2C communication protocol to show text data. It’s widely used in embedded and IoT projects to display information such as temperature, sensor values, time, and status messages.

✅ Key Features:

  • Displays text only (not graphics)
  • Usually 16×2 (16 characters x 2 lines) or 20×4
  • Has an I2C backpack (PCF8574 chip) that allows communication using just 2 pins: SDA (data) and SCL (clock)
  • Saves GPIO pins, compared to traditional 6- or 8-pin LCD control

🧰 Components Used

ComponentDescription
ESP32 Dev BoardMicrocontroller (WiFi + BLE)
I2C LCD 16×2Text display with I2C backpack
Jumper WiresMale-to-female wires
Breadboard (opt.)For cleaner wiring
Arduino IDEFor programming ESP32

🔌 I2C LCD Pinout and Connection to ESP32

I2C LCD PinESP32 PinFunction
VCC3.3V or 5VPower supply
GNDGNDGround
SDAGPIO 21I2C Data
SCLGPIO 22I2C Clock

📌 The I2C address is usually 0x27 or 0x3F


🧪 How I2C LCD Works

  • The I2C backpack on the LCD uses the PCF8574 chip, which acts as an I/O expander.
  • This chip converts 2-wire I2C signals into the parallel signals needed to control the LCD.
  • The ESP32 sends commands/data over SDA/SCL, and the chip handles display logic.

⚙️ Operating Principle

  • The LCD has two rows: Row 0 and Row 1.
  • Each row supports 16 characters (in a 16×2 LCD).
  • You control the cursor to set where text appears.
  • The LiquidCrystal_I2C library simplifies the process.

🧱 Arduino Setup

🧩 Step 1: Install Required Libraries

In Arduino IDE:

  1. Go to Sketch > Include Library > Manage Libraries
  2. Search and install:
    • ✅ LiquidCrystal_I2C (by Frank de Brabander or compatible)

💡 LCD Functions Summary

FunctionPurpose
lcd.init()Start communication
lcd.backlight()Turn on display backlight
lcd.setCursor(x, y)Move cursor to (x: column, y: row)
lcd.print("text")Print text to current cursor
lcd.clear()Clear entire screen

✅ Common Problems & Fixes

IssueSolution
No text on screenTry other I2C address (e.g., 0x3F)
Characters not showingAdd lcd.backlight()
Random charactersUse correct column/row sizes
Display frozenCheck connections and address

🎯 Real-world Applications

ProjectDescription
Temperature MonitorShow sensor readings (DHT11/22)
WiFi Status DisplayShow IP address or signal strength
RTC Clock DisplayShow time/date from RTC module
SMS Viewer with SIM900Display incoming SMS messages
Sensor DashboardGas, sound, light sensors status

HOW TO OPERATE

#include <LiquidCrystal_I2C.h>

#include “DHT.h”

#define DHTPIN 18

#define LIG 2  

LiquidCrystal_I2C lcd(0x27,20,4);

void setup() {

  Serial.begin(9600);

  Serial.println(“DHTxx test!”);

  lcd.init();

lcd.backlight();

  dht.begin();

}

void loop() {

  delay(2000);

  lcd.setCursor(0,0);

  lcd.println(“HELLO IOTWEBPLANET”);

}

ESP32 + I2C LCD for Real-Time Feedback

Share this post

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Back to Tutorial