How to USE ESP8266 Control LCD Display?


Posted January 20, 2025 by chipmall

We make a lot of ESP8266 based projects, and although most of them are for IOT and web based projects, it's handy to have a local LCD screen to see what's happening.

 
We make a lot of ESP8266 based projects, and although most of them are for IOT and web based projects, it's handy to have a local LCD screen to see what's happening.

I2C is perfect for I/O devices without a lot of available I/O pins, as it only uses two I/O pins. These LCD modules are common, but have a variety of addresses, so let's get you communicating with the ESP8266, connect the screen to the esp8266 module, and run a I2C address scanner to see what address we need to communicate with. The following steps will get you sorted.

Hardware Overview
A typical I2C LCD display consists of an HD44780 based character LCD display and an I2C LCD adapter. Let us get to know them one by one.



Character LCD Display
True to their name, these LCDs are ideal for displaying only text/characters. A 16×2 character LCD, for example, has an LED backlight and can display 32 ASCII characters in two rows of 16 characters each.If you look closely you can see tiny rectangles for each character on the display and the pixels that make up a character. Each of these rectangles is a grid of 5×8 pixels.

I2C LCD Adapter

At the heart of the adapter is an 8-bit I/O expander chip – PCF8574. This chip converts the I2C data from an ESP8266 into the parallel data required for an LCD display.

pcf8574 chip on i2c lcd

The board also comes with a small trimpot to make fine adjustments to the display’s contrast.

i2c lcd adapter hardware overview

In addition, there is a jumper on the board that supplies power to the backlight. To control the intensity of the backlight, you can remove the jumper and apply external voltage to the header pin that is marked ‘LED’.



I2C Address of LCD

If you are using multiple devices on the same I2C bus, you may need to set a different I2C address for the LCD adapter so that it does not conflict with another I2C device.

To do this, the adapter has three solder jumpers (A0, A1 and A2) or solder pads.

i2c address selection jumpers on i2c lcd

Each of these is used to hardcode the address. If a jumper is shorted with a blob of solder, it sets the address.An important point here is that several companies manufacture the same PCF8574 chip, Texas Instruments and NXP Semiconductors, to name a few. And the I2C address of your LCD depends on the chip manufacturer.

If your LCD has Texas Instruments’ PCF8574 chip:According to the Texas Instruments’ datasheet, the three address selection bits (A0, A1 and A2) are placed at the end of the 7-bit I2C address register.

texas instruments pcf8574 i2c address register

Since there are 3 address inputs, which can take 2 states, either HIGH/LOW, we can therefore create 8 (23) different combinations (addresses).

By default, all 3 address inputs are pulled HIGH using onboard pullups, giving the PCF8574 a default I2C address of 0100111Binary or 0x27Hex.

By shorting the solder jumpers, the address inputs are pulled LOW. If you were to short all three jumpers, the address would be 0x20. The range of all possible addresses spans from 0x20 to 0x27. Please see the illustration below.

i2c lcd address selection jumper table for ti

If your LCD has NXP’s PCF8574 chip:

According to the NXP Semiconductors’ datasheet, the three address selection bits (A0, A1 and A2) are also placed at the end of the 7-bit I2C address register. But the other bits in the address register are different.

nxp semiconductors pcf8574 i2c address register

Since there are 3 address inputs, which can take 2 states, either HIGH/LOW, we can therefore create 8 (23) different combinations (addresses).

By default, all 3 address inputs are pulled HIGH using onboard pullups, giving the PCF8574 a default I2C address of 0111111Binary or 0x3FHex.

By shorting the solder jumpers, the address inputs are pulled LOW. If you were to short all three jumpers, the address would be 0x38. The range of all possible addresses spans from 0x38 to 0x3F. Please see the illustration below.

i2c lcd address selection jumper table for nxp

So your LCD probably has a default I2C address 0x27Hex or 0x3FHex. However it is recommended that you find out the actual I2C address of the LCD before using it.

Luckily there’s an easy way to do this. We will see that later in the tutorial.

https://www.chipmall.com/products/detail/wifi-modules_olimex-ltd-esp8266-evb_c95653503

I2C LCD display Pinout

An I2C LCD has only 4 pins that connect it to the outside world. The connections are as follows:

i2c lcd display pinout

GND is a ground pin. Connect it to the ground of the ESP8266.

VCC supplies power to the module and LCD. Connect it to the ESP8266’s VIN pin or an external 5V power supply.

SDA is the I2C data pin. Connect it to the ESP8266’s I2C data pin.

SCL is the I2C clock pin. Connect it to the ESP8266’s I2C clock pin.

Wiring an I2C LCD Display to an ESP8266

Connecting I2C LCD to ESP8266 is very easy as you only need to connect 4 pins. Start by connecting the VCC pin to the VIN on the ESP8266 and GND to ground.

Now we are left with the pins which are used for I2C communication. We are going to use the default I2C pins (GPIO#4 and GPIO#5) of the ESP8266. Connect the SDA pin to the ESP8266’s D2 (GPIO#4) and the SCL pin to the ESP8266’s D1 (GPIO#5).

The following table lists the pin connections:

I2C LCD ESP8266

VCC

VIN

GND

GND

SCL

D1

SDA

D2

The following diagram shows you how to wire everything up.



wiring i2c lcd display to esp8266

Adjusting The LCD Contrast

After wiring up the LCD you’ll need to adjust the contrast of the display. On the I2C module you will find a potentiometer that you can rotate with a small screwdriver.Plug in the ESP8266’s USB connector to power the LCD. You will see the backlight lit up. Now as you turn the knob on the potentiometer, you will start to see the first row of rectangles. If that happens, Congratulations! Your LCD is working fine.testing esp8266 i2c lcd contrast by turning potentiometer

Once this is done, we can start programming the LCD.
-- END ---
Share Facebook Twitter
Print Friendly and PDF DisclaimerReport Abuse
Contact Email [email protected]
Issued By chipmall
Phone 075583957775
Business Address Rm 4301,Century Place Duhuixuan,No.3018 Shennan Middle Rd,Futian Dist,Shenzhen,518031 China
Country China
Categories Accounting , Affiliate Program
Tags esp8266 , pcf8574
Last Updated January 20, 2025