Interface I2C LCD Using NodeMCU

73,784

50

17

Introduction: Interface I2C LCD Using NodeMCU

About: " Work until you no longer have to introduce yourself " Show some love on Instagram @makers_bee & Motivate me on YouTube @MakersBee

Wassup Makers!!

In this Instructables we will learn how to interface an LCD (Liquid Crystal Display) to the NodeMCU board.

These 16x2 LCDs are very popular and broadly used in electronics projects as they are good for displaying information like sensor data from your project, and also they are very cheap.

Step 1: Things Needed

We need few components to get started with the Instructable,

Hardware Components

  • NodeMCU
  • 16x2 LCD
  • I2C Board
  • Breadboard
  • Jumper Wires
  • Micro USB Cable

Software Components

  • Arduino IDE

Step 2: Circuit Connection

Connecting LCD to I2C and then interfacing it to NodeMCU is very simple.

The LCD’s registers from D0 to D7 and Vcc, GND, RS, R/W pins will be connected to I2C.

GND pin of I2C is connected Ground pin (GND) of the NodeMCU.

VCC pin of I2C is connected Vin pin of the NodeMCU. (Because we need to supply 5v to LCD)

SDA pin of I2C is connected D4 of the NodeMCU.

SCL pin of I2C is connected D3 pin of the NodeMCU.

Before you get started with coding you need Arduino IDE.To download Arduino IDE and for NodeMCU setup, you can check my previous instructacle.

"Interfacing Servo Motor With NodeMCU"

Step 3: Coding Time Begins

#include <Wire.h>

#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x3F, 16, 2);
void setup(){
  Wire.begin(2,0);
  lcd.init();   // initializing the LCD
  lcd.backlight(); // Enable or Turn On the backlight 
  lcd.print(" Hello Makers "); // Start Printing
}
void loop(){
  // Nothing Absolutely Nothing!
}

First thing we need to do is to insert the Liquid Crystal Library. We can do that like this:

Sketch > Include Library > Manage Libraries > LiquidCrystal_I2C LCD

Download the "LCD.ino" file and open it up in the Arduino IDE.

Then Create a new sketch and paste the code below in the Arduino IDE and hit Upload You can tinker with the code to make it more useful or just use it as it is.

Attachments

Step 4: Output

Now, you can develop this instructable to all your sensor based projects and implement in many other applications.

That's all makers!

I hope you found this instructable most useful. You can contact me by leaving a comment. If you like this instructable probably you might like my next ones.

Makerspace Contest 2017

Participated in the
Makerspace Contest 2017

1 Person Made This Project!

Recommendations

  • Teach With Tinkercad Contest

    Teach With Tinkercad Contest
  • Fandom Contest

    Fandom Contest
  • Plywood Contest

    Plywood Contest

17 Comments

0
poharescrz
poharescrz

Tip 3 months ago

I think the Wire.begin() syntax is Wire.begin(SDA, SCL);. So, for the code to match the diagram it would be Wire.begin(4,3);. I also connected my display's LCD Vcc to Vin on the NodeMCU which differs from the diagram. It works for me with these changes.

0
DannyON4CLU
DannyON4CLU

Reply 3 months ago

Could I use other GPIO pins, for example D6 and D8 like: Wire.begin(D6,D8); ?
All other GPIO pins on my NodeMCU are assigned to 1. SPI OLED display 2. ublox GPS receiver.
If I Serial.print() SDA,SCL on the serial monitor, it prints 4,5.

0
KvajayK
KvajayK

2 years ago

made connection same, code loaded , but not working. no display.

0
Irfan0402
Irfan0402

Reply 9 months ago

i know it's late but..i've found some solution for this problem..at least it was for me..try change "lcd.backlight();" to "lcd.setBacklight((uint8_t)1);

0
rakinanwar2862
rakinanwar2862

Reply 1 year ago

have you found the solution to this?

0
KvajayK
KvajayK

Reply 2 years ago

anybody please help..

WhatsApp Image 2020-03-10 at 5.40.46 PM.jpegWhatsApp Image 2020-03-10 at 5.40.47 PM.jpegWhatsApp Image 2020-03-10 at 5.40.46 PM (1).jpeg
0
KvajayK
KvajayK

Reply 2 years ago

anybody can help , i dont know , where i made mistake.. done connect and code as per the above procedure , but not working.

0
rakinanwar2862
rakinanwar2862

Question 1 year ago

please tell us which library you've used

0
rehmanrao123rao7
rehmanrao123rao7

2 years ago

there is an error
exit status 1
within this context

0
HafijulH
HafijulH

2 years ago

Can you please specify the Library name with programmer or library link . Using NodeMCU version 1 Not Working

0
jaseemec
jaseemec

Question 3 years ago

how to interface non i2c 16x2 lcd to nodemcu without shift register ICs.

0
WaelS19
WaelS19

3 years ago

I have the same question as JesusM173. Where do you get the library? I downloaded one from another site and i keep getting the error below.

invalid conversion from 'int' to 't_backlighPol' [-fpermissive]

0
JesusM173
JesusM173

Question 3 years ago on Step 3

he copiado el programa en un nodemcu v3 de lolin en el IDE y cuando lo clequeo me aparece el siguiente error: Tampoco me funciona lo de dar corriente a traves del pin Vin a la lcd, le proporciono corriente a traves de un pin 3,3V

Arduino:1.8.5 (Windows 10), Tarjeta:"NodeMCU 1.0 (ESP-12E Module), 80 MHz, 4M (1M SPIFFS), v2 Lower Memory, Disabled, None, Only Sketch, 115200"
Opciones de compilación cambiadas, reconstruyendo todo
C:\Users\MORGAN\Downloads\LCD\LCD.ino: In function 'void setup()':
LCD:14: error: 'class LiquidCrystal_I2C' has no member named 'init'
lcd.init(); // initializing the LCD
^
exit status 1
'class LiquidCrystal_I2C' has no member named 'init'
Este reporte podría tener más información con
"Mostrar salida detallada durante la compilación"
opción habilitada en Archivo -> Preferencias.

1
JesusM173
JesusM173

3 years ago

Cual es la url para descargar la librería liquidcrystal_i2c?

0
ArthurM99
ArthurM99

Question 4 years ago

Hi,

How do you make your circuit diagrams?

0
CodeChamp
CodeChamp

Answer 4 years ago

I use Adobe Photoshop. : )