Interface I2C LCD Using NodeMCU

21,027

39

6

About: " Work until you no longer have to introduce yourself " Show some love on Instagram @it.is.prem & Motivate me on YouTube @TheCircuit

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.

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.

Share

    Recommendations

    • Arduino Contest 2019

      Arduino Contest 2019
    • Trash to Treasure

      Trash to Treasure
    • Tape Contest

      Tape Contest

    6 Discussions

    0
    None
    jaseemec

    Question 10 days ago

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

    0
    None
    WaelS19

    7 weeks 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
    None
    JesusM173

    Question 3 months 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.

    0
    None
    JesusM173

    3 months ago

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

    0
    None
    ArthurM99

    Question 11 months ago

    Hi,

    How do you make your circuit diagrams?

    1 answer