ESP32 S3 - LCD 20x4

In this tutorial, we walk you through displaying text on a 20x4 LCD screen using I2C communication with the ESP32 S3 board. This beginner-friendly guide makes it easy to add a large, readable display to your ESP32 S3 projects.

What you'll build:

  1. A working LCD 20x4 I2C display connected to your ESP32 S3
  2. Text output across all four rows of the display
  3. Precisely positioned messages using cursor coordinates
  4. A foundation for sensor readouts, menus, and data dashboards
ESP32 S3 - LCD 20x4

Hardware Preparation

1×ESP32 S3 WROOM N16R8
1×USB Cable Type-A to Type-C (for USB-A PC)
1×USB Cable Type-C to Type-C (for USB-C PC)
1×LCD 20x4
1×Jumper Wires
1×Optionally, DC Power Jack

Or you can buy the following kits:

1×DIYables Sensor Kit (18 sensors/displays)
Disclosure: Some of the links provided in this section are Amazon affiliate links. We may receive a commission for any purchases made through these links at no additional cost to you.
Additionally, some of these links are for products from our own brand, DIYables .

Buy Note: Alternatively, you can assemble the LCD I2C display using LCD 1602 Display and PCF8574 I2C Adapter Module.

Overview of LCD I2C 20x4

The LCD I2C 20x4 is a liquid crystal display module that shows 20 characters per line across 4 rows, communicating with your microcontroller over just two wires using the I2C protocol. It combines the spacious display area of a traditional parallel LCD with the simplicity of I2C, making it an excellent choice for projects that need to show multiple lines of information without consuming many GPIO pins.

Key Specifications

The LCD I2C 20x4 offers a display capacity of 20 columns by 4 rows, giving you 80 characters of total space. It communicates over I2C using only two data wires (SDA and SCL), and operates at 5V. The default I2C address is typically 0x27, though this can vary by manufacturer. A built-in LED backlight (available in blue or green) illuminates the display, and contrast is adjustable via a small onboard potentiometer. Compared to parallel LCD displays, the I2C version is far easier to wire and leaves more GPIO pins free for sensors and actuators.

Pinout

The LCD 20x4 I2C module exposes just four pins, keeping connections minimal and straightforward.

  1. GND: Ground pin — connect to GND (0V)
  2. VCC: Power supply pin — connect to 5V
  3. SDA: I2C data line — carries serial data between the module and the ESP32 S3
  4. SCL: I2C clock line — provides the serial clock signal
LCD 20x4 I2C Pinout

LCD Coordinate

Understanding the LCD coordinate system lets you position text precisely anywhere on the screen. Columns are numbered 0 to 19 from left to right, and rows are numbered 0 to 3 from top to bottom. The top-left corner is position (0, 0) and the bottom-right corner is position (19, 3). Use setCursor(column, row) in your code to move the cursor before printing text.

ESP32 S3 LCD I2C Coordinate

Wiring Diagram

Connect the LCD 20x4 I2C display to your ESP32 S3 using the wiring table below, keeping in mind that the LCD requires 5V while the ESP32 S3 communicates at 3.3V logic (the I2C module handles the level difference). Two wiring configurations are shown depending on how you power your board.

Safety Notes

When powering the ESP32 S3 through the USB port, you can supply the LCD display from the VBUS pin, eliminating the need for an external power source. However, the VBUS pin may not deliver sufficient current for the LCD to function reliably under all conditions, so an external 5V power supply through the DC power jack is the more dependable option for permanent installations.

  • USB-Powered Setup: When powering ESP32 S3 via USB port
The wiring diagram between ESP32 S3 LCD 20x4 I2C

This image is created using Fritzing. Click to enlarge image

  • External Power Setup: When powering ESP32 S3 via Vin pin
The wiring diagram between ESP32 S3 LCD 20x4 I2C external power source

This image is created using Fritzing. Click to enlarge image

LCD I2C ESP32 S3
VCC 5V
GND GND
SDA GPIO8
SCL GPIO9

How To Program For LCD I2C

The DIYables_LCD_I2C library abstracts the low-level I2C communication details so you can focus on placing text on screen rather than managing the display protocol. The library initializes the hardware, controls the backlight, and provides intuitive methods for cursor positioning and text printing that work seamlessly with the ESP32 S3.

The following code initializes the LCD at I2C address 0x27 with 20 columns and 4 rows, turns on the backlight, then uses setCursor() to position text on each of the four rows before calling lcd.print() to display the message. No repeated updates are needed in the loop since the content is static.

Include the Library

#include <DIYables_LCD_I2C.h> // Library for LCD

Declare LCD Object

DIYables_LCD_I2C lcd(0x27, 20, 4); // I2C address 0x27, 20 column and 4 rows

Initialize the LCD

lcd.init(); //initialize the lcd lcd.backlight(); //open the backlight

Set Cursor Position

lcd.setCursor(column_index, row_index);

Print Text Message

lcd.print("Hello World!");

※ NOTE THAT:

The I2C address of LCD can vary according to the manufacturers. In the code, we used 0x27 that is specified by DIYables manufacturer

ESP32 S3 Code

/* * This ESP32 S3 code was developed by newbiely.com * * This ESP32 S3 code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/esp32-s3/esp32-s3-lcd-20x4 */ #include <DIYables_LCD_I2C.h> DIYables_LCD_I2C lcd(0x27, 20, 4); // I2C address 0x27, 20 column and 4 rows void setup() { lcd.init(); // Initialize the LCD I2C display lcd.backlight(); lcd.setCursor(0, 0); // move cursor the first row lcd.print("LCD 20x4"); // print message at the first row lcd.setCursor(0, 1); // move cursor to the second row lcd.print("I2C Address: 0x27"); // print message at the second row lcd.setCursor(0, 2); // move cursor to the third row lcd.print("DIYables"); // print message at the third row lcd.setCursor(0, 3); // move cursor to the fourth row lcd.print("www.diyables.io"); // print message the fourth row } void loop() { }

Detailed Instructions

  1. New to ESP32 S3? Complete our Getting Started with ESP32 S3 guide first.
  2. Connect the hardware: Wire the LCD 20x4 I2C to your ESP32 S3 following the wiring diagram above.
  3. Plug in USB cable: Connect the ESP32 S3 to your computer using a USB Type-C cable.
  4. Open Arduino IDE: Launch the Arduino IDE software on your computer.
  5. Select your board: Choose ESP32 S3 and the correct COM port from the Arduino IDE.
  6. Install the library: Click the Library Manager icon on the left sidebar of Arduino IDE.
  7. Search for library: Type "DIYables LCD I2C" in the search box.
  8. Install DIYables library: Find the DIYables_LCD_I2C library by DIYables and click Install.
  • Search for DIYables LCD I2C created by DIYables.io and click the Install button.
Newbiely | Arduino IDE 2.3.8
──
File
Edit
Sketch
Tools
Help
ESP32S3 Dev Module
Library Manager
Type:
All
Topic:
All
DIYables LCD I2C by DIYables.io
This library is designed for HD44780-based I2C LCD displays. It provides LiquidCrystal-compatible API plus helper functions (text alignment, progress bars, predefined custom characters). Supports multiple I2C buses (Wire, Wire1, Wire2) for advanced boards like Arduino Giga, Due, and ESP32. Compatible with all Arduino-based platforms including Arduino Uno, Mega, Nano, ESP32, ESP8266, STM32, and Raspberry Pi Pico. More info
1.0.0
INSTALL
Newbiely.ino
···
1 void setup() {
Output
Serial Monitor
Ln 1, Col 1
ESP32S3 Dev Module on COM15
1
  1. Copy the code: Paste the example code above into Arduino IDE.
  2. Upload the code: Click the Upload button to transfer code to your ESP32 S3.
  3. View the display: Check the LCD screen — you should see text on all four rows.
  4. Experiment: Try changing the text content and cursor positions to customize the display.
  5. Pro Tip: If nothing appears on the LCD, adjust the small potentiometer on the back of the I2C module to increase contrast until the text becomes visible.

Application Ideas

The ESP32 S3 paired with an LCD 20x4 I2C display is a versatile combination well-suited to projects that need to present multiple lines of live or static information at a glance.

  1. Weather station: Display temperature, humidity, pressure, and forecast on four dedicated rows.
  2. Smart thermostat: Show current temperature, target temperature, mode, and schedule simultaneously.
  3. Multi-sensor data logger: Present readings from several sensors on screen at the same time.
  4. Home automation controller: Build a menu-driven interface for toggling and configuring devices.
  5. Real-time clock: Show date, time, day of week, and alarm status across the four rows.
  6. Audio player interface: Display song title, artist, album, and playback progress.
  7. Network monitor: Show IP address, connection status, signal strength, and data usage in real time.

Video Tutorial

Watch the step-by-step video walkthrough for this ESP32 S3 project below.

...VIDEO Z5z8MnJXb_s

Challenge Yourself

These progressive challenges will help you build on what you have learned and push your ESP32 S3 LCD skills further.

  1. Beginner: Display your name on the first row and your favorite quote spread across rows 2 through 4.
  2. Beginner: Create a countdown timer that updates the seconds remaining on the LCD each second.
  3. Intermediate: Read temperature from a DHT11 sensor and display the value with a custom degree symbol on the LCD.
  4. Intermediate: Build a scrolling text marquee that smoothly moves a long message across the screen.
  5. Advanced: Create a multi-screen menu system that cycles through different information panels every 5 seconds.
  6. Advanced: Design a real-time system monitor showing WiFi status, uptime, memory usage, and live sensor data across all four rows.

※ OUR MESSAGES

  • As freelancers, We are AVAILABLE for HIRE. See how to outsource your project to us
  • Please feel free to share the link of this tutorial. However, Please do not use our content on any other websites. We invested a lot of effort and time to create the content, please respect our work!