GUIDES HOW TOHow to Interface PCF8574 I2C LCD with ESP8266 NodeMCU?

How to Interface PCF8574 I2C LCD with ESP8266 NodeMCU?

-

In this article, you will be able to learn about how to Interface PCF8574 I2C LCD with ESP8266 NODEMCU motherboard. Here you will also learn about the PCF8574 I2C LCD working method and coding system.
Before going ahead you must know about PCF8574 I2C LCD Module and LCD Display. Here a question arises that what is PCF8574 LCD. So the answer is that the PCF8574 I2C LCD is a unique designed module with lengths of 16×2 and 20×4 LCD Display with shows different readings.

you can also refer to the below article.

How to Interface oled display with Esp32 ?

 Interface PCF8574 I2C LCD with ESP8266 NodeMCU

Need for I2C LCD

Let’s know a little bit about ESP8266 nodemcu. It is the best motherboard ever developed for the Internet or online applications. The main thing in this pin is the GPIO Pins ????.  For SPI Flash IC and UART use all the GPIO related pins are removed and then 9 GPIO pins ????  can be used for free.
But in this DIY project ESP8266, NodeMCU uses 6 GPIO pins ????.  Even if the communication mode is in 4-bit parallel mode. The distribution of the 6 GPIO pins is explained as four pins are used for Data, one for RS and one for E.
NOTE ????:  If you had planned to use other important sensors and devices for this project then the number of GPIO pins must be reduced as using that many pins for the LCD display is not possible.
After using other sensors the I2C LCD Module can be fully used, as its unique designed LCD Display and communication process take place through the I2C interface. As a result instead of 6 GPIO Pins 2 pins are used which are named as SDA and SCL of I²C.

A Brief Look at PCF8574 I2C LCD Module

As the article clearly shows the headline of today’s DIY project, you should know that the PCF8574 I2C LCD Module is designed on the basis of PCF8574 GPIO Expander IC. Actually,  the expander is used for the expansion of a microcontroller and it also controls its communication with it through the I2C interface.

Interface PCF8574 I2C LCD with ESP8266 NodeMCU

Another characteristic of the I2C LCD Module is to show the result of the experiment on the LCD or to drive the characters on LCD. It also has a connection or designed potentiometer for contrast management and a jumper for controlling Backlights.

Interface PCF8574 I2C LCD with ESP8266 NodeMCU

ESP8266 NodeMCU I2C LCD

Let’s get started with the actual DIY project working method. If you guys have read our other articles then you must know that ESP8266 NodeMCU pins D1 and D2 are known as GPIO 5 and GPIO 4. These pins are mostly used for I²C communication purposes.
ABOUT PINS;
 D1 or GPIO 5 = SCL Pin  D2 or GPIO 4 = 0SDA Pin
Both these pins are used to connect with the PCF8574 I2C LCD Module.
For connecting purposes, LCD should be simply plugged into these pins and supply power for display purposes.

Interface PCF8574 I2C LCD with ESP8266 NodeMCU

The given diagram shows the connections between the I2C LCD Module and ESP8266 NodeMCU.

I2C LCD Module ESP8266 NodeMCU
GND GND
VCC VIN
SDA D2 – GPIO 4
SCL D1 – GPIO 5
NOTE: The LCD display needs a power supply between 4.7 V to 5.3V, PCF8574 IC required power supply is 2.5 V to 6V, from NodeMCU 5V power, is supplied instead of 3.3V.

Components Required

Components Required
  • ESP8266 NodeMCU
  • PCF8574 I2C
  • LCD Module 16×2
  • Character LCD Display
  • Breadboard
  • Connecting Wires

Circuit Diagram

The given image shows ESP8266 NodeMCU I2C LCD Interface.

 Interface PCF8574 I2C LCD with ESP8266 NodeMCU

Preparing Arduino IDE

For the completion of this DIY project you need to know some of these Preparing steps to avoid errors and to give perfection ???? and if you have never used the I2C LCD Module before then follow the steps.
Steps
  1. STEP 1: Open Arduino IDE
  2. STEP 2: Click on Tools -> then go to manage libraries.
  3. STEP 3: Now in the searching bar type ” LiquidCrystal_I2C ” library by Frank de Brabander.

Interface PCF8574 I2C LCD with ESP8266 NodeMCU

Getting the Slave Address of I2C LCD Module

Before going ahead let une tell you that slave address is most important code for displaying on LCD. If you are an expert then you must know that main basic of I2C communication is that if a master had to communicate with a slave only if slave address is known.
In this DIY project the ESP8266 NodeMCU is the master and the PCF8574 I2C LCD Module is the slave.
So, use the given code to get the slave address of LCD Module. After completing all the necessary setup, add the code to Interface PCF8574 I2C LCD with ESP8266 NodeMCU and open the Serial Monitor.

Code

Here is the code text,
#include <Wire.h>

void setup()
{
  Wire.begin();
  Serial.begin(115200);
  while (!Serial);
}

void loop()
{
  byte error, address;
  int I2CDevices;

  Serial.println("Scanning for I2C Devices…");

  I2CDevices = 0;
  for (address = 1; address < 127; address++ )
  {
    Wire.beginTransmission(address);
    error = Wire.endTransmission();

    if (error == 0)
    {
      Serial.print("I2C device found at address 0x");
      if (address < 16)
      {
        Serial.print("0");
      }
      Serial.print(address, HEX);
      Serial.println(" !");

      I2CDevices++;
    }
    else if (error == 4)
    {
      Serial.print("Unknown error at address 0x");
      if (address < 16)
      {
        Serial.print("0");
      }
      Serial.println(address, HEX);
    }
  }
  if (I2CDevices == 0)
  {
    Serial.println("No I2C devices found\n");
  }
  else
  {
    Serial.println("****\n");
  }
  delay(5000);
}

 

 

ESP8266 will look for any slaves and if a slave

The system works by detecting or searching for any slave and when it’s slave is acknowledged, the ESP8266 will scan its address and will print it on serial Monitor.As from the imaged you can clearly see that the slave address is 0×3F in my case. This code is used as main code.

Interface PCF8574 I2C LCD with ESP8266 NodeMCU

Displaying Simple Text

While further moving ahead with the step wise process, now let’s see how simple text is displayed on 16×2 LCD. No extra connection are needed.

Code

#include <Wire.h> 
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x3F, 16, 2);

void setup()
{
  lcd.init();
  lcd.backlight();
  lcd.setCursor(0,0);
  lcd.print("  I2C LCD with ");
  lcd.setCursor(0,1);
  lcd.print("ESP8266 NodeMCU");
  
}


void loop()
{
  
}

 

 

 Interface PCF8574 I2C LCD with ESP8266 NodeMCU

ADC Value on LCD

In this project small circuit is also created by joining 10 KΩ Potentiometer to ADC pin of NodeMCU and shows the result of ADC on LCD using the I2C LCD Module.
As the ESP8266 has specified quality as it’s ADC has a revolution of 10-bit so it’s output range will relay between 0 to 1023.
NOTE : you should know that ESP8266 had only ADC Channel , as on NodeMCU Board, A0 is the number of ADC Pin. The 10 KΩ Potentiometer of the wiper pin is attattached with A0 of NodeMCU and at the same time other two pins of the potentiometer are attached to 3.3V and GND.
WARNING:  POT can only Tolerate voltage upto 3.3V, so be careful with connecting POT with ESP8266 ADC.

Circuit Diagram

The given below images shows the connections of Potentiometer to ESP8266 NodeMCU and also displaying the ADC result on the I2C LCD.

Interface PCF8574 I2C LCD with ESP8266 NodeMCU

Code

#include <Wire.h> 
#include <LiquidCrystal_I2C.h>

#define analogPin A0 /* ESP8266 Analog Pin ADC0 = A0 */
int adcValue = 0;  /* Variable to store Output of ADC */

LiquidCrystal_I2C lcd(0x3F, 16, 2);

void setup()
{
  lcd.init();
  lcd.backlight();
  lcd.setCursor(0,0);
  lcd.print("ADC Value =      ");
    
}


void loop()
{
  adcValue = analogRead(analogPin); /* Read the Analog Input value */
  lcd.setCursor(0,0);
  lcd.print("ADC Value =      "); 
  lcd.setCursor(12, 0);
  lcd.print(adcValue);
  delay(1000);
}

 

 

Interface PCF8574 I2C LCD with ESP8266 NodeMCU

Conclusion

After reading this article with full attention and by following the step you might have a complete project in your hands now. You did a great job by going through all this complex process, now thing might be easy for you and you had also learnt uses and importance of Interface PCF8574 I2C LCD with ESP8266 NodeMCU and works.
For any kind of difficulty comment down below or contact us through email ???? ????.
Thank you ❤️
Aizaz khan
Aizaz khanhttps://myelectricsparks.com/aizaz-khan/
Aizaz was the first person to get a byline on his blog on technology from his home in Bannu in 2017. Then, he went on to a career in breaking things professionally at my electric sparks which is where he eventually took over the kit as a hardware editor. Today, as the senior editor of hardware for my electric sparks, he spends time reporting about the most recent developments in the hardware industry and technology. If he's not reporting on hardware or electronics, you'll see him trying to be as remote from the world of technology as possible through camping in the wild.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest news

About Tech

You might also likeRELATED
Recommended to you