Contents
I2C LCD Display With 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.
How to Connect I2C with ESP8266 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).
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.
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.
How to Identify communication address
To do this, the adapter has three solder jumpers (A0, A1 and A2) or solder pads.
By shorting the solder jumpers, the address inputs are pulled LOW. If you were to short all three jumpers, the address would be 0x38 or 0x27. The range of all possible addresses spans from 0x38 to 0x3F.
I2C LCD display Pinout
An I2C LCD has only 4 pins that connect it to the outside world. The connections are as follows:
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.
important Connection
1. SDA is the I2C data pin. Connect it to the ESP8266’s I2C data pin.
2. 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.
Connection Details:
I2C LCD ESP8266
VCC —— VIN
GND—— GND
SCL ——-D1
SDA—— D2
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.
Library Installation
To drive an I2C LCD you must first install a library called LiquidCrystal_I2C
To install the library navigate to Sketch > Include Libraries > Manage Libraries… Wait for Library Manager to download the library index and update the list of installed libraries
How to Find I2C Address using Arduino ide
#include <LiquidCrystal_I2C.h> void setup() { Wire.begin(); Serial.begin(115200); Serial.println("\nI2C Scanner"); } void loop() { byte error, address; int nDevices; Serial.println("Scanning..."); nDevices = 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.println(address,HEX); nDevices++; } else if (error==4) { Serial.print("Unknow error at address 0x"); if (address<16) { Serial.print("0"); } Serial.println(address,HEX); } } if (nDevices == 0) { Serial.println("No I2C devices found\n"); } else { Serial.println("done\n"); } delay(5000); } Upload the reset and open serial monitor.
How to Display words with I2C.
#include <LiquidCrystal_I2C.h> int lcdColumns = 16; int lcdRows = 2; LiquidCrystal_I2C lcd(0x27, lcdColumns, lcdRows); void setup() { // initialize LCD lcd.init(); // turn on LCD backlight lcd.backlight(); } void loop() { lcd.setCursor(0, 0); lcd.print(" androiderode "); delay(1000); lcd.setCursor(0,1); lcd.print("Thanks to all"); delay(1000); lcd.clear(); }