Arduino and ESP8266 With I2c LCD Display
by Fernando Koyanagi in Circuits > Arduino
9606 Views, 4 Favorites, 0 Comments
Arduino and ESP8266 With I2c LCD Display
![Arduino e ESP8266 com Display i2c LCD](/proxy/?url=https://content.instructables.com/FJN/0KZ2/JFIIR7EA/FJN0KZ2JFIIR7EA.jpg&filename=Arduino e ESP8266 com Display i2c LCD)
![1.png](/proxy/?url=https://content.instructables.com/FJX/T3HU/JFIIR7EN/FJXT3HUJFIIR7EN.png&filename=1.png)
Our main objective here is to show the operation of the serial i2c module for LCD Display 2x16 or 20x4. With this module, we can control the displays mentioned above while using only two pins (SDA and SCL). This makes communication very simple and frees up several other of our microcontroller’s GPIOs.
Let's show the operation on both the UNO and ESP8266 Arduino. Check it out!
Arduino Uno
![arduino uno.png](/proxy/?url=https://content.instructables.com/FZE/I7U7/JFIIR7EJ/FZEI7U7JFIIR7EJ.png&filename=arduino uno.png)
WiFi ESP8266 NodeMcu ESP-12E
![WiFi ESP8266 NodeMcu ESP-12E.png](/proxy/?url=https://content.instructables.com/FGS/EXRT/JFIIR7F1/FGSEXRTJFIIR7F1.png&filename=WiFi ESP8266 NodeMcu ESP-12E.png)
16x2 Serial LCD Display
![Display LCD 16x2 Serial.png](/proxy/?url=https://content.instructables.com/FKI/2BOQ/JFIIR7FM/FKI2BOQJFIIR7FM.png&filename=Display LCD 16x2 Serial.png)
I2c Serial Module
![Módulo Serial i2c.png](/proxy/?url=https://content.instructables.com/FIM/2AJB/JFIIR7GC/FIM2AJBJFIIR7GC.png&filename=Módulo Serial i2c.png)
In this part, we show the adapter that was bought separately. We welded the display, which is parallel, in the back. Through the i2c pins, the display will then communicate directly with the Arduino. Therefore, through a microcontroller, this Arduino will manage all the commands to the display, facilitating both its connection and programming.
I2c Serial Module Connected to the LCD Display
![Módulo Serial i2c conectado no Display LCD.png](/proxy/?url=https://content.instructables.com/FNB/P7DA/JFIIR7H3/FNBP7DAJFIIR7H3.png&filename=Módulo Serial i2c conectado no Display LCD.png)
Mounting With Arduino
![Montagem com Arduino.png](/proxy/?url=https://content.instructables.com/F9A/N53L/JFIIR7I2/F9AN53LJFIIR7I2.png&filename=Montagem com Arduino.png)
Mounting With ESP8266
![Montagem com ESP8266.png](/proxy/?url=https://content.instructables.com/FWA/H0R7/JFIIR7J1/FWAH0R7JFIIR7J1.png&filename=Montagem com ESP8266.png)
Library
Add the "LiquidCrystal_I2C" library for communication with the LCD display.
Access the link and download the library.
Unzip the file and paste it into the libraries folder of the Arduino IDE.
C: / Program Files (x86) / Arduino / libraries
Source Code
We start by defining the libraries and constants we will use with our code.
#include <Wire.h> // responsável pela comunicação com a interface i2c #include <LiquidCrystal_I2C.h> // responsável pela comunicação com o display LCD // Inicializa o display no endereço 0x27 //os demais parâmetros, são necessários para o módulo conversar com o LCD //porém podemos utilizar os pinos normalmente sem interferência //parâmetro: POSITIVE > > Backligh LIGADO | NEGATIVE > > Backlight desligado LiquidCrystal_I2C lcd(0x27,2,1,0,4,5,6,7,3, POSITIVE);
Setup
Here, we will only initialize our object for communication with the display.
void setup() { //inicializa o display (16 colunas x 2 linhas) lcd.begin (16,2); // ou 20,4 se for o display 20x4 }
Loop
Our program will make the display blink every 1 second. This is a simple program that already involves everything we need to communicate with the display.
Turn on / off backlight, position cursor for writing.
void loop() { //acende o backlight do LCD lcd.setBacklight(HIGH); //posiciona o cursor para escrita //.setCursor(coluna, linha) lcd.setCursor(0,0); lcd.print("FERNANDOK.COM"); lcd.setCursor(0,1); lcd.print("ACESSE!!!"); delay(1000); //intervalo de 1s //desliga o backlight do LCD lcd.setBacklight(LOW); delay(1000); //intervalo de 1s }