Electronics News Updates

Using a 16×2 I2c Lcd Display With Esp32

A few weeks ago, we examined the features of ESP32 module and built a simple hello world program to get ourselves familiar with the board. Today, we will continue our exploration of the ESP32 on a higher level as we will look at how to interface a 16×2 LCD with it.

Displays provide a fantastic way of providing feedback to users of any project and with the 16×2 LCD being one of the most popular displays among makers, and engineers, its probably the right way to start our exploration. For today’s tutorial, we will use an I2C based 16×2 LCD display because of the easy wiring it requires. It uses only four pins unlike the other versions of the display that requires at least 7 pins connected to the microcontroller board.

ESP32 comes in a module form, just like its predecessor, the ESP-12e, as a breakout board is usually needed to use the module. Thus when it’s going to be used in applications without a custom PCB, it is easier to use one of the development boards based on it. For today’s tutorial, we will use the DOIT ESP32 DevKit V1 which is one of the most popular ESP32 development boards.

To demonstrate the use of I2C driven LCD with the NodeMCU, we will examine how to display both static and scrolling messages on the LCD.

REQUIRED COMPONENTS

The following components are required to build this project;

  1. DOIT ESP32 DevKit V1 board
  2. Breadboard
  3. A 16×2 I2C LCD display
  4. Jumper Wires

The breadboard requirement is optional as you can choose to connect the LCD directly to the DOIT devkit board using female-female jumper wires.

Schematics

The schematics for this project is relatively simple since we are connecting just the LCD to the DOIT Devkit v1. Since we are using I2C for communication, we will connect the pins of the LCD to the I2C pins of the DevKit. Connect the components as shown below.

Schematic Using a 16×2 I2c Lcd Display With Esp32

A pin map showing how the components are connected is shown below.

LCD – ESP32

GND - GND
VCC - 3.3v/Vin
SDA - D2(GPIO4)
SCL - D1 (GPIO 5)

Due to the power requirements of the LCD, it may not be bright enough when connected to the 3.3v pin of the ESP32. If that is the case, connect the VCC pin of the LCD to the Vin Pin of the ESP32 so it can draw power directly from the connected power source.

Detecting the I2C Address of the LCD

At this point, it is important to note that a special setup is required to enable you to use the Arduino IDE to program ESP32 based boards. We covered this in the introduction to ESP32 tutorial published a few weeks go. So, be sure to check it out.

To be able to easily write the code to interact with the I2C LCD display, we will use the I2C LCD library. The Library possesses functions and commands that make addressing the LCD easy. Download the I2C LCD library from the link attached and install on the Arduino IDE by simply extracting it into the Arduino’s library folder.

Before writing the code for the project, it’s important for us to know the I2C address of the LCD as we will be unable to talk to the display without it.

While some of the LCDs come with the address indicated on it or provided by the seller, in cases where this is not available, you can determine the address by using a simple sketch that sniffs the I2C line to detect what devices are connected alongside their address. This sketch is also a good way to test the correctness of your wiring or to determine if the LCD is working properly.

For More Details: Using a 16×2 I2c Lcd Display With Esp32

Tags

Related Articles

Leave a Reply

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

Back to top button
Close
Close