Menu Close

NodeMCU 16×2 LCD on Arduino IDE

This tutorial explains how to use 16×2 LCD on NodeMCU wifi development board using Arduino IDE.

1. Introduction:

This tutorial explains how to use LCD for displaying purpose on ESP8266 NodeMCU development board using Arduino IDE. We are using 16×2 character LCD in this tutorial. 

2. Circuit

The basic setup of ESP should be done along with basic setup make the following circuit.
We are using I2C LCD backpack here in this tutorial. Mount 16×2 LCD to the I2C LCD backpack.

3. Header File

You will need to replace your Liquid Crystal Library with the library available at following link. You make take a copy of your existing library for future. 

This library file should be placed at the install folder of Arduino. I have a 64 bit Win7 OS and my arduino library folder address is located at

C:\Program Files (x86)\Arduino\libraries 

You may download library file from here.

4. Programming 

Before moving ahead to the programming you must know the i2c device no of the LCD Backpack, here is a tutorial of Robo India for I2C scanning.

I2C Scanner

once you know i2c address of LCD, Download the following sketch update it with your i2c address before uploading code to NodeMCU.

You may download following sketch from here.

/*
16X2 LCD Tutorial by ROBO INDIA
http://roboindia.com/
*/
#include <LiquidCrystal_I2C.h>
// Construct an LCD object and pass it the 
// I2C address, width (in characters) and
// height (in characters). Depending on the
// Actual device, the IC2 address may change.
LiquidCrystal_I2C lcd(0x3F, 16, 2);

void setup() {
 lcd.begin(16,2);     // The begin call takes the width and height. This
 lcd.init();          // Should match the number provided to the constructor.
 lcd.backlight();     // Turn on the backlight.
 lcd.setCursor(0, 0); // Move the cursor characters to the right and
                      // zero characters down (line 1).
 lcd.print("HELLO");  // Print HELLO to the screen, starting at 0,0.

  
 lcd.setCursor(0, 1);    // Move the cursor to the next line and print
 lcd.print("WORLD");     // WORLD.  
  }

void loop() {
}

5. Output

Successful upload of the above code prints Hello in the first line and World in the second line. As we have printed something else on the following image. 

If you have any query please write us at support@roboindia.com

Thanks and Regards
Content Development Team 
Robo India
https://roboindia.com







Leave a Reply