I2C LCD with ESP32

Adding an I2C LCD display to an ESP32 microcontroller involves a few steps, including hardware connections and software configuration. Here’s a step-by-step guide to help you.

Hardware Required:
1. ESP32 Development Board: Such as the ESP32 DevKitC.
2. I2C LCD Display: Typically a 16×2 or 20×4 character LCD with an I2C interface.
3. Connecting Wires: wires or jumper wires.

Hardwae Connections:
1. Wire Connections:
LCD VCC to ESP32 3.3V or 5V
LCD SDA to ESP32 SDA pin (usually GPIO21 on ESP32).
LCD SCL to ESP32 SCL pin (usually GPIO22 on ESP32).
Ensure to connect the pull-up resistors (usually built into the LCD module).

Software Setup (Arduino IDE):
To program the ESP32 and control the I2C LCD, follow these steps:

1. Install Required Libraries:
Open the Arduino IDE.
Navigate to Sketch > Include Library > Manage Libraries.
Search for and install the following libraries if not already installed:
LiquidCrystal_I2C by Frank de Brabander

2. Write the Arduino Sketch:
Use the following example sketch to test your setup. Adjust the I2C address (0x27 is common, but your module might have a different address) and adjust the pin numbers if your connections differ.

#include <wire> 
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,16,2); 

void setup() 
lcd.print(" I2C LCD with "); 
void loop() 

3. Upload the Sketch:
Connect your ESP32 board to your computer via USB.
Select the correct board and port under Tools > Board and
Tools > Port in Arduino IDE.
Click the upload button to upload the sketch to your ESP32.

4. Testing:
After uploading, the LCD should display “I2X LCD with, ANDROIDERODE.COM” if everything is connected correctly.

Troubleshooting Tips:
Check Connections:
Ensure all wires are securely connected and the correct pins are used.

Library Compatibility:
Make sure the LiquidCrystal_I2C library is installed and correctly referenced in your sketch.

I2C Address:
If the LCD doesn’t display correctly, verify the I2C address using an I2C scanner sketch (search online for examples).

Power Supply: Ensure your ESP32 board can supply enough current for the LCD and that voltage levels are compatible.

By following these steps, you should be able to successfully add and control an I2C LCD display with your ESP32 microcontroller. Adjust the code as needed for your specific display and requirements.


Subramanian MK, currently serving as a workshop instructor at Sakthi Polytechnic College, Erode Tamil Nadu. With a career spanning 25 + years, Subramanian MK has dedicated himself to advancing knowledge in Electronics and Communication Engineering (ECE). His passion for exploring new technologies has led to the development of numerous projects, showcasing expertise in IoT and PCB design.

Articles: 504

Leave a Reply

Your email address will not be published. Required fields are marked *

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


Hi, How can I help you?