lcd module rcf8574 free sample

In this tutorial, you’ll learn how to use ESP32 (or ESP8266) with the I2C LCD Display module (PCF8574) in Arduino IDE. We’ll be using the LiquidCrystal_I2C library with I2CWire.h library in Arduino Core to interface LCD 16×2 display via the I2C bus.

The I2C IO expander IC (PCF8574) is commonly used as a cheap solution to implement an I2C LCD interface that replaces the classic parallel connection to the LCDs (at least 6 pins) with an easy to use I2C bus (only 2 pins).

In this section, we’ll only discuss the important things in order to get started with these modules as quickly as possible and control them with ESP32 or ESP8266 boards.

As you know, the 3 non-fixed value bits in the address allow us to make 8 different combinations. And potentially be able to use up to 8 different I2C LCD devices on the same bus at the same time.

Now, I’ve got 2 I2C LCD modules with 2 unique addresses (0x27, 0x26). And those are the two I’ll be using in LAB21 to show you how to use multiple I2C LCDs with ESP32 at the same time. All of this information does apply to any number of modules up to 8 on the same bus.

In this section, I’ll show you the library we’ll be using (LiquidCrystal_I2C), how to install it in Arduino IDE, how to make the ESP32 to I2C LCD module connections, and what are different API functions available to use in the library.

The connection between ESP32 & I2C LCD module should be as follows. Note that the Wire library by default uses the I2C0 module & its default pins are GPIO21 & GPIO22, as we’ve stated in the previous I2C tutorial.

The code example down below does the following: We start with defining an object of LiquidCrystal_I2C, set its parameters, and initialize the LCD. Then, we’ll print “Hello World!” at the home position. Next, we’ll set the cursor to point at the 2nd row and print another string of text. And that’s all!

The LCD display’s controller (Hitachi HD44780) supports up to 8 custom characters that you can create and store on the LCD itself. Then you can send the Index of each custom character to be displayed later. Maybe 8 custom characters are not enough for your project, but it’s one little extra feature that you can occasionally use.

In this example, we’ll be defining two I2C LCD objects with similar parameters except for the address. The 1st LCD will be @ 0x26 and the 2nd one will be @ 0x27.

We’ll initialize both of them, and write a different message on each LCD to check that addressing is working as it should be. And that’s all about this LAB.

ESP32 I2C LCD module can be used in so many applications as we’ll see in future tutorials. I’ll keep updating this series of tutorials by adding more applications and techniques that may help you in your projects. Drop me a comment if you’ve got any questions or suggestions, I’ll be glad to help!

lcd module rcf8574 free sample

A regular LCD requires a lot of wires (parallel interface) to be connected with a Microcontroller.The Serial LCD  backpack built on PCF8574 IC uses the I2C bus to convert  the parallel interface to a serial one.This needs only2 wires SDA & SCL , apart from the power connections.

The blue preset is to adjust the contrast of the LCD. The black jumper on the left is to enable the Backlight of LCD. The I2C device has a HEX address by which a microcontroller can communicate with it.This is set by the 3 bits A0,A1 ,A2 .If no jumper is present , it is HIGH &  a jumper means LOW. By default all the 3 jumpers are open . ie., A0,A1 A2 all are 1s.

lcd.setBacklightPin(HIGH);  makes the P3 pin go High, which turns on the NPN transistor.This provides GND to the LED pin of LCD As the other LED pin is already connected to Vcc through the jumper , the LCD backlight glows.

lcd module rcf8574 free sample

The next step is to download and install the Arduino I2C LCD library for use with the backpack. First of all, rename the "LiquidCrystal" library folder in your Arduino libraries folder. We do this just to keep it as a backup.

Now restart the Arduino IDE if it was already running - or open it now. To test the module we have a demonstration sketch prepared, simply copy and upload the following sketch:/* Demonstration sketch for PCF8574T I2C LCD Backpack

After a few moments the LCD will be initialised and start to display our URL and the value for millis, then blink the backlight off and on. If the text isn"t clear, or you just see white blocks - try adjusting the contrast using the potentiometer on the back of the module.

lcd module rcf8574 free sample

Generally to be able to use an LCD display we need at least 6 free pins, but the number of pins can be minimized with the help of external components like PCF8574 (or PCF8574A) I2C I/O expander, that’s allows us to use only 2 pins from our microcontroller. This small post shows how to connect the Arduino with I2C LCD provided with PCF8574 I/O expander.

The main component of the I2C LCD display is the PCF8574 I/O expander, with only two pins SDA and SCL we get a maximum of 8 pins from P0 to P7. PCF8574A also can be used but it has a different address.

lcd module rcf8574 free sample

There are modules that can be soldered or stacked to the display that offers an I2C interface for communication instead of the 8+ digital lines that are used to send data to the display.

lcd module rcf8574 free sample

Add any 16x2 or 20x4 LCD-screen with a Hitachi HD44780 controller using either a port expander connected through I2c or just wire through GPIO 4 or 8 bit.

1 LCD-screen Hitachi HD44780 controller (PCF8574, or MCP23008 or MCP23017) with an I2c port expander. Or just wire through GPIO 4 or 8 bit. We recommend using a LCD-screen with an I2c port expander as it uses less wire (only 4) and is faster and more stable.

If your LCD has a PCF8574T chip from Texas Instruments, its default I2C address is 0x27Hex. If your LCD has a PCF8574AT chip from NXP semiconductors, its default I2C address is 0x3FHex. So your LCD probably has an I2C address 0x27Hex or 0x3FHex.

R2: Potentiometers: 10K Ohms. Controls the contrast and brightness of the LCD. Using a simple voltage divider with a potentiometer, we can make fine adjustments to the contrast.