Connecting LCD Display (LCD1602) to the ESP32
We are going to connect an LCD1602 character display fitted with an I2C adapter to the ESP32. From a wiring point of view, the setup looks simple because only four connections are required: power, ground, SDA, and SCL. However, even though the wiring count is small, there is an important voltage detail that we must handle correctly before making any connections.
Voltage compatibility problem
The voltage tolerance of ESP32 GPIO pins is 3.6 V. If the voltage on a GPIO pin exceeds 3.6 V, it is outside the safe operating range and may cause damage to the chip.
Most LCD1602 modules with an I2C backpack are designed to run at 5 V. The I2C backpack usually has pull-up resistors connected to its supply voltage. When powered at 5 V, this means SDA and SCL idle at 5 V.
If SDA and SCL from such a module are connected directly to the ESP32, the ESP32 GPIO pins will be exposed to 5 V. This is the core problem we must address.
A commonly suggested shortcut you will see online
Many online tutorials suggest powering the LCD1602 and its I2C backpack from 5 V and connecting SDA and SCL directly to the ESP32. I have tested this setup myself, and it does work. However, it is electrically unsafe, and long-term use might damage the ESP32 GPIO pins.
For this reason, even though it functions, this wiring method should not be considered safe or recommended.
Note
This topic is frequently discussed in the ESP32 community. Some users report that 5 V inputs appear to work in hobby projects, while others point out that this behavior is not specified by Espressif and should not be relied on, especially for commercial or long-term designs. One of the related discussions can be found here: https://www.reddit.com/r/esp32/comments/1j5p0lb/can_the_espwroom32_read_5v_io_inputs/
The lazy but reasonably safe approach: power everything at 3.3 V
For demos, experiments, and learning projects, the simplest and safest approach is to power the LCD1602 I2C module from the ESP32 3.3 V supply instead of 5 V.
When the LCD backpack is powered at 3.3 V, its I2C pull-up resistors pull SDA and SCL to 3.3 V instead of 5 V. This immediately removes the voltage compatibility problem, and SDA and SCL can be connected directly to the ESP32.
The trade-off is reduced LCD contrast and backlight brightness. When powered at 3.3 V, the display is typically still readable under normal indoor lighting conditions, which is sufficient for experiments and basic verification.
This approach avoids extra components and avoids stressing the ESP32 GPIO pins.
| LCD Pin | Wire | ESP32 Pin | Notes |
|---|---|---|---|
| GND |
|
GND | Ground |
| VCC |
|
3.3 | 3.3 Power Supply |
| SCL |
|
GPIO 18 | Connects the clock signal (SCL) for I2C communication. |
| SDA |
|
GPIO 23 | Connects the data signal (SDA) for I2C communication. |
Best approach: Using a level shifter
If you need full backlight brightness, or if your LCD module does not work reliably at 3.3 V, then you must power it at 5 V. But this means you need to protect the ESP32 from the 5 V signals.
The solution is a bidirectional logic level converter (also called a level shifter). This small module converts signals between 3.3 volts and 5 volts in both directions.
The ESP32 connects to the 3.3 V side of the level shifter, and the LCD connects to the 5 V side. The level shifter makes sure the ESP32 only ever sees 3.3 V signals, while the LCD gets the 5 V signals it needs.
This is the electrically correct and safe method, but it adds a few extra wires and requires an additional module.
The circuit diagram may look a little confusing at first glance, but the idea is simple once you break it down.
Power Connections (Connect These First)
First, connect the ESP32 3.3 V output to the pin marked LV (Low Voltage) on the level shifter. This defines the logic level for the ESP32 side. Next, connect the ESP32 5 V supply (i.e VIN in ESP32 Devkit V1 board) to the pin marked HV (High Voltage) on the level shifter. The LCD VCC pin is also powered from this same 5 V supply.
Ground must be common, so connect ESP32 GND, the level shifter GND, and the LCD GND together.
| From | Pin | Wire | To | Pin | Purpose |
|---|---|---|---|---|---|
| ESP32 | GND |
|
Level Shifter | GND | Common ground |
| Level Shifter | GND |
|
LCD Display | GND | Common ground |
| ESP32 | 3.3V |
|
Level Shifter | LV | Low voltage logic reference |
| ESP32 | VIN / 5V |
|
Level Shifter | HV | High voltage logic reference |
| ESP32 | VIN / 5V |
|
LCD Display | VCC | 5V power supply for the LCD |
Data Connections (I2C Communication)
Now connect the I2C signal lines. The ESP32 GPIO pins must always connect to the pins on the level shifter marked LVx, and the LCD I2C pins must connect to the corresponding pins marked HVx.
In this example, the ESP32 SDA pin connects to LV1, and the LCD SDA pin connects to HV1. The ESP32 SCL pin connects to LV2, and the LCD SCL pin connects to HV2. The exact GPIO numbers used for SDA and SCL depend on your ESP32 board and software configuration.
| From | Pin | Wire | To | Pin | Purpose |
|---|---|---|---|---|---|
| ESP32 | GPIO 23 (SDA) |
|
Level Shifter | LV1 | SDA (Data) - ESP32 side |
| Level Shifter | HV1 |
|
LCD Display | SDA | SDA (Data) - LCD side |
| ESP32 | GPIO 18 (SCL) |
|
Level Shifter | LV2 | SCL (Clock) - ESP32 side |
| Level Shifter | HV2 |
|
LCD Display | SCL | SCL (Clock) - LCD side |
How it works
In simple terms, when the ESP32 communicates over an I2C line, the LVx side operates at 3.3 V, and the level shifter presents a 5 V signal on the matching HVx side for the LCD. When the LCD communicates at 5 V, the level shifter translates that signal back so the ESP32 only ever sees 3.3 V on the LVx side. This way, both devices operate at their required voltages without stressing the ESP32 GPIO pins.