ESP32 S3 UNO - LCD 20x4
This ESP32 S3 Uno LCD 20x4 tutorial shows you how to connect a 20x4 LCD I2C display to the ESP32 S3 Uno form board and print text on it. The LCD 2004 has four rows of 20 characters, and it needs only two data wires. At the end, you will see your own messages on all four lines of the screen.
In this tutorial, you will:
- Wire an LCD I2C 20x4 to the A4 and A5 pins
- Install the DIYables LCD I2C library in Arduino IDE
- Place the cursor on any column and row of the LCD 2004
- Write Arduino code that prints text on all four rows

Hardware Preparation
Or you can buy the following kits:
| 1 | × | DIYables Sensor Kit (18 sensors/displays) |
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 2004 Display and PCF8574 I2C Adapter Module.
Overview of LCD I2C 20x4
A 20x4 LCD with an I2C backpack is a simple way to show a lot of text from your ESP32 S3 Uno. The backpack board on its back turns the many parallel LCD pins into just two I2C signal wires. This saves pins for your other parts.
Pinout
The LCD 20x4 I2C module has four pins. Two of them give power, and two of them carry the I2C signals.
| Pin | What It Does |
|---|---|
| GND | Connect to ground (0V) |
| VCC | Power for the LCD, connect to 3.3V |
| SDA | I2C data signal |
| SCL | I2C clock signal |

LCD Coordinate
You tell the LCD where to write by giving it a column and a row. The screen has 20 columns and 4 rows, and both numbers start at 0. So the top-left cell is (0, 0) and the bottom-right cell is (19, 3).

ESP32 S3 Uno Pinout
The image below shows the pinout of the ESP32 S3 Uno form board. Use it to find the A4 (GPIO5) and A5 (GPIO4) pins before you wire the LCD.

Wiring Diagram
The LCD talks over I2C. Connect its SDA to A4 and its SCL to A5. The code moves I2C to these pins with Wire.setPins(5, 4).

This image is created using Fritzing. Click to enlarge image
| LCD I2C Pin | ESP32 S3 Uno Pin |
|---|---|
| VCC | 3.3V |
| GND | GND |
| SDA | A4 (GPIO5) |
| SCL | A5 (GPIO4) |
For a project that lasts, screw terminals hold the wires better than jumper wires. Try a Screw Shield V2 or a Proto Screw Terminal Block Shield: it sits on the ESP32 S3 Uno, and each pin gets its own screw terminal. The wiring stays the same. Only the wires now go to the screw terminals, as shown below.

This image is created using Fritzing. Click to enlarge image
※ NOTE THAT:
On this board, the default I2C pins are the SDA (GPIO8) and SCL (GPIO9) header pins. This tutorial moves I2C to A4 (GPIO5) and A5 (GPIO4) with Wire.setPins(5, 4) in the code. This way the wiring matches the diagram, and you can use the A4 and A5 screw terminals of a screw shield. If you wire the LCD to the SDA and SCL header pins instead, remove that line.
WARNING
The ESP32 S3 Uno pins are NOT 5V tolerant. Power the LCD from the 3.3V pin, so SDA and SCL stay at 3.3V.
How To Program For LCD I2C
The DIYables_LCD_I2C library does the hard work for you. You only need a few lines of code to set up the screen and print text.
Include the library
Create the LCD object
Give it the I2C address, the number of columns, and the number of rows.
Start the LCD
Call these lines once in setup(). The first line moves I2C to A4 and A5. The other two start the screen and turn on its backlight.
Move the cursor
Pick the column and the row where the next text will start.
Print a message
※ NOTE THAT:
The I2C address can be different from one LCD maker to another. This example uses 0x27, the address given by DIYables. If your screen stays blank, run an I2C scanner sketch to find your LCD's address.
ESP32 S3 Uno Code
The sketch below starts the LCD and writes one line of text on each of the four rows. All the work happens in setup(), so the text appears once and stays on the screen. The loop() is empty.
On the ESP32 S3 Uno, the Wire library uses the SDA (GPIO8) and SCL (GPIO9) header pins by default. The code calls Wire.setPins(5, 4) before lcd.init(), so the LCD works on A4 (GPIO5) and A5 (GPIO4) instead. If you wire the LCD to the SDA and SCL header pins, remove that line.
Detailed Instructions
Follow these steps in order:
- New to the ESP32 S3 Uno? Follow ESP32 S3 Uno - Getting Started first.
- Wire it up as shown in the diagram.
- Connect the board to your computer with a USB Type-C cable.
- Open Arduino IDE, choose the ESP32S3 Dev Module board and the correct COM port.
- Open the Library Manager by clicking the Libraries icon on the left side of Arduino IDE.
- Search for the library by typing "DIYables LCD I2C", and find the DIYables_LCD_I2C library by DIYables.
- Install it by clicking the Install button.
- Search for DIYables LCD I2C created by DIYables.io and click the Install button.
- Copy the code above and paste it into Arduino IDE.
- Upload the code by clicking the Upload button.
- Check the LCD. You should see four lines of text.
- Tip: Change the text and the cursor positions, then upload again to see how the layout changes.
The USB port may not give enough power for the LCD backlight. If the screen is dim or shows no characters, power the LCD from an external 5V source. A power splitter set makes this easy, as shown below:

Video Tutorial
Watch the video below to see this ESP32 S3 Uno project step by step.
The video demo is a small RFID door lock. It shows the system state on the 20x4 LCD, opens a servo door for the right card, and beeps a buzzer. After three wrong cards, it locks for a short time. The demo code is below. It needs the MFRC522 and ESP32Servo libraries.
WARNING
In this demo, the RFID SS pin goes to D10 (GPIO10), the RFID RST pin goes to D9 (GPIO46), the servo goes to D6 (GPIO3) and the buzzer goes to D8 (GPIO21). The RFID module uses SPI on D11 (GPIO11), D12 (GPIO13) and D13 (GPIO12). D6 (GPIO3) and D9 (GPIO46) are boot strapping pins. If the board does not boot or upload, unplug the servo and RFID RST wires, upload, then plug them back in.
FAQ
Which pins of the ESP32 S3 Uno do I use for the LCD 20x4 I2C?
Wire SDA to A4 (GPIO5) and SCL to A5 (GPIO4). By default, the Wire library uses the SDA (GPIO8) and SCL (GPIO9) header pins. The code calls Wire.setPins(5, 4) to move I2C to A4 and A5. This lets you use the A4 and A5 screw terminals of a Uno screw shield, which has no SDA and SCL screws. If you wire the LCD to the SDA and SCL header pins instead, remove that line.
Can I power the LCD 20x4 from 3.3V?
Yes. In this tutorial the LCD VCC goes to the 3.3V pin of the ESP32 S3 Uno.
Is the I2C signal safe for the ESP32 S3 Uno?
Yes. The LCD is powered from 3.3V on this board, so SDA and SCL stay at 3.3V.
How do I find the I2C address of my LCD 20x4?
Common addresses are 0x27 and 0x3F. Upload an I2C scanner sketch and open the Serial Monitor. It prints the address of every I2C device it finds. Put that address in the DIYables_LCD_I2C line.
Is the code different from the Arduino UNO R4 code?
Only a little. The wiring is the same: the LCD goes to A4 and A5 on both boards. The ESP32 S3 Uno code only adds the Wire.setPins(5, 4) line, because A4 and A5 are not the default I2C pins on this board. Remove that line to run the code on the UNO R4.
What if my project needs more pins than the Uno headers give?
The ESP32 S3 Uno has two extra rows of holes with more GPIOs. GPIO15 and GPIO16 work as I/O, PWM and analog. GPIO45 and GPIO35 to GPIO42 work as I/O and PWM. GPIO47 and GPIO48 are output only, with PWM. Solder pin headers to use them, and write the GPIO number in code. For an LCD project with extra buttons, GPIO35 to GPIO42 are good inputs; do not use GPIO47 or GPIO48 for inputs. Two warnings: (1) GPIO47 and GPIO48 may run at 1.8V instead of 3.3V on some modules (especially ones with "V" in the name, like R8V or R16V), so 3.3V devices can be damaged or act strangely. (2) GPIO0, GPIO3 (D6), GPIO45 and GPIO46 (D9) are boot strapping pins, and a wrong connection can stop the board from booting or uploading code. Use the other extra pins first.
Troubleshooting
| Problem | Possible Cause | Solution |
|---|---|---|
| No COM port in Arduino IDE | USB driver missing or the board is not in upload mode | Install the CP210x or CH340 driver. Or hold BOOT while you press RESET, then upload |
| LCD backlight is on but no text | Wrong I2C address | Run an I2C scanner sketch and use the address it prints, often 0x27 or 0x3F |
| LCD shows a row of white boxes | Contrast is not set right | Turn the small blue potentiometer on the back of the LCD slowly |
| Nothing works and the backlight is off | Wiring or power problem | Check VCC goes to 3.3V and GND goes to GND. Try an external 5V supply |
| LCD does not respond | SDA and SCL wired to other pins than the code uses | Wire SDA to A4 (GPIO5) and SCL to A5 (GPIO4), and keep the Wire.setPins(5, 4) line in setup() |
| Text is dim or flickers | USB power is not enough | Power the LCD from an external 5V source with a shared GND |
| Compile error about DIYables_LCD_I2C.h | Library not installed | Install the DIYables_LCD_I2C library from the Library Manager |
| Text is cut off or wraps wrongly | Text is longer than 20 characters | Keep each line to 20 characters or less and set the cursor for each row |