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
| Component | Description |
|---|---|
| ESP32 Dev Board | Microcontroller (WiFi + BLE) |
| I2C LCD 16×2 | Text display with I2C backpack |
| Jumper Wires | Male-to-female wires |
| Breadboard (opt.) | For cleaner wiring |
| Arduino IDE | For programming ESP32 |
🔌 I2C LCD Pinout and Connection to ESP32
| I2C LCD Pin | ESP32 Pin | Function |
|---|---|---|
| VCC | 3.3V or 5V | Power supply |
| GND | GND | Ground |
| SDA | GPIO 21 | I2C Data |
| SCL | GPIO 22 | I2C 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 0andRow 1. - Each row supports 16 characters (in a 16×2 LCD).
- You control the cursor to set where text appears.
- The
LiquidCrystal_I2Clibrary simplifies the process.
🧱 Arduino Setup
🧩 Step 1: Install Required Libraries
In Arduino IDE:
- Go to Sketch > Include Library > Manage Libraries
- Search and install:
- ✅
LiquidCrystal_I2C(by Frank de Brabander or compatible)
- ✅
💡 LCD Functions Summary
| Function | Purpose |
|---|---|
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
| Issue | Solution |
|---|---|
| No text on screen | Try other I2C address (e.g., 0x3F) |
| Characters not showing | Add lcd.backlight() |
| Random characters | Use correct column/row sizes |
| Display frozen | Check connections and address |
🎯 Real-world Applications
| Project | Description |
|---|---|
| Temperature Monitor | Show sensor readings (DHT11/22) |
| WiFi Status Display | Show IP address or signal strength |
| RTC Clock Display | Show time/date from RTC module |
| SMS Viewer with SIM900 | Display incoming SMS messages |
| Sensor Dashboard | Gas, 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”);
}


Leave a Reply
You must be logged in to post a comment.