Tutorials

Interfacing 16X2 LCD Module with ESP32 with and without I2C

Learn how to interface a 16X2 LCD modules like LCD1602 with and without I2C adapter to ESP32 WiFi and Bluetooth Board.

In this quick tutorial we are going to connect an 16X2 character LCD module to ESP 32. Usually as ESP 32 has built in WiFi we can display the data through the internet using online dashboard on Computers or mobile devices but there are some cases where the data should be shown on simple displays connected directly to board like printing the sensor data, simple count down, displaying scrolling text and more. Mainly we can use these modules when there is no internet connectivity used in a project.  So lets start by knowing the basics, pin out diagrams, circuit diagrams, with few examples.

This interfacing can be done through two methods:

  1. By connecting directly to LCD module with out using I2C module.
  2. By connecting with the help of I2C adapter.

Requirements:

  • LCD 16X2 module with or without I2C adapter
  • 10K potentiometer
  • ESP32 Development Board
  • Wires for connection
  • 5V power supply (Micro USB or External).

I2C Adapter Module:

I2C Serial Interface Adapter Module

This module has a PCF8574T chip which can handle 16X2 and 20X4 displays and has an inbuilt potentiometer to adjust the contrast. with a jumper for Turning on and off the Backlight of the display.

ESP32 Pinout:

Click to enlarge

Method 1) Interfacing 16X2 LCD module with ESP 32 without using I2C adapter

In this method we are connecting the LCD module to ESP by using 12 connecting wires from 16 pins on the LCD Display. This method is relatively complex when compared with another method as it includes bunch of connecting wires which allocates more number of pins on ESP32.

Lets connect them by following the below Schematic diagram.

Circuit Diagram:

Interfacing 16X2 LCD module with ESP 32 without using I2C adapter
Click to enlarge.

As you can see from the above circuit diagram we have added a 10 K Potentiometer which is used to adjust the contrast of the LCD display so the the characters are visible clearly.  We used the LCD display which need a voltage of 5V we connected it to the VIN of the ESP where we can get 5V while microUSB is connected to the ESP 32. If you are using an external power supply 5v to ESP through VIN then connect the same wire to the LCD where 5V is required.

Look at the below table  for detailed pin connections between ESP32, LCD and potentiometer.

LCD Pin – >ESP32 Pins

  • PIN01-VSS -> GND
  • PIN02-VDD -> 5V
  • PIN03 V0-> 10K Pot (Middle pin)
  • PIN04 RS->  GPIO19
  • PIN05 RW-> GND
  • PIN06  E  ->  GPIO23
  • PIN07 D0-> NOT USED
  • PIN08 D1-> NOT USED
  • PIN09 D2-> NOT USED
  • PIN10 D3-> NOT USED
  • PIN11 D4->  GPIO18
  • PIN12 D5->  GPIO17
  • PIN13 D6->  GPIO16
  • PIN14 D7->  GPIO15
  • PIN15 A-> 5V
  • PIN16 K-> GND

Program code:

To run this program you need to install a library Liquidcrystal, If it not installed on your Arduino IDE download from this Link.

Copy and paste the below code on Arduino IDE and Select the COM port of ESP32 and Board as ESP 32 Wrover module and Click on Upload.

After Uploading the code the LCD display shows the below output.

Interfacing LCD Display with ESP32 output

For more Example codes like scrolling text and adding custom character please refer our previous article where we explained them along with the code. here

Method 2:Interfacing 16X2 LCD module with ESP 32 using I2C adapter

In this method we are using an I2C adapter which is connected to LCD display with 16 pins and outputs only 4 pins, 2 for data and another 2 for power and ground. The I2C adapter has inbuit potentiometer where we can adjust the contrast of the display and also has a jumper to turn on/off the LCD backlight.

Lets connect them by observing the below schematic diagram.

Circuit Diagram:

interfacing lcd module to esp 32 with I2c adapter circuit
Click to enlarge

As you can see from the above circuit diagram the VCC and GND pins are connected to the 5V and GND respectively and the other two data pins SDA and SCL are connected to D21 and D22 respectively. to know which are the SDA and SCL pins of your ESP 32 Board check the pin out diagram.

Before getting into work we need to find the I2C address of the I2C adapter generally it will be 0x27 for for some modules it will be different so copy and paste the below code to find the I2C address in the serial monitor.

Code to get the I2C address:

After Uploading the code the serial monitor will show the following output:

scanning the i2c address for lcd moduleNow you can prepare the code for displaying the data on the LCD module.

Program code:

after uploading the code the output text will be displayed on the LCD Module as shown in below image.

Interfacing 16X2 LCD Module with ESP32 output with I2cFor more examples please refer the link provided in the method 1.

Video Demonstration:

Interfacing 16x2 LCD module with ESP 32- Quick Tutorial.

If you have any doubts please feel free to ask below and if you like our articles please follow us on social networks which inspires us to make more interesting projects.

CircuitSchools Staff

We at CircuitSchools publish on basics of electronics and electric components and everything related to evolution of electrical technology with complete analysis of development boards and modules along with latest projects with innovative ideas.

Related Articles

Back to top button