I2C LCD on NodeMCU V2 With Arduino IDE

72,446

12

13

Introduction: I2C LCD on NodeMCU V2 With Arduino IDE

In this quick instructable I'll show you how to lunch LCD with I2C Serial Adapter on NodeMCU v2 using ArduinoIDE and available libraries.

Step 1: Required Parts and Software

Hardware:

1. NodeMCU v2

2. 16x2 LCD Display with i2c Serial Interface Adapter Module

3. Some wires, USB for power supply and sketch uploading

Software:

1. ArduinoIDE - https://www.arduino.cc/en/main/software

2. LiquidCrystal_I2C library - https://github.com/fdebrabander/Arduino-LiquidCrystal-I2C-library

Step 2: Hardware Setup

Preparations:

When you order LCD from Ali/ebay you can solder 16 pin headers to LCD display in order to avoid 'wiring mess' when connecting to serial adapter

Setup:

  1. Place LCD display and Serial Adapter on bread board next to each other
  2. Connect adapter's SCL pin with NodeMCU D1 pin
  3. Connect adapter's SDA pin with NodeMCU D2 pin
  4. Connect adapter's GND, VCC pins with NodeMCU GND, Vin accordingly - here I need to explain one thing. Basically you should connect LCD display to 5v source but NodeMCU only has 3.3v outputs so the LCD is pretty dark. If you provide LCD with external 5v source you'll need to use logic level converter because it will not work. Here I used some hack using USB provided power that is bypassed to Vin. It's 5V but it works :)

Step 3: The Sketch

Preparations:

  1. Install ArduinoIDE
  2. Add NodeMCU support - nicely described here.
  3. Add LiquidCrystal_I2C library - please use instructions provided by author. Installation from AdruinoIDE will add outdated version


The Sketch:

#include <LiquidCrystal_I2C.h>

#include <Wire.h>

LiquidCrystal_I2C lcd(0x27, 16, 2);

void setup() {

Serial.begin(115200);

//Use predefined PINS consts

Wire.begin(D2, D1);

lcd.begin();

lcd.home();

lcd.print("Hello, NodeMCU");

}

void loop() { // do nothing here }

---------------------

Upload the sketch and you're done!

Be the First to Share

    Recommendations

    • Microcontroller Contest

      Microcontroller Contest
    • Automation Contest

      Automation Contest
    • Make it Glow Contest

      Make it Glow Contest

    13 Comments

    0
    ar.khan9983ar
    ar.khan9983ar

    Question 4 months ago on Step 1

    after connecting with Vin , as you mentioned its 5V : ) LCD is not turning on . I also connected 16 to 4 pin converter with LCD
    0
    kuzayet3
    kuzayet3

    5 months ago

    Please, I am using a 3v NodeMCU. My LCD lights come on but I tried uploading the code but it doesn't display. I adjusted the potentiometer/contrast but still no text displayed. I need your help please

    0
    HimajaK1
    HimajaK1

    Question 2 years ago on Step 3

    Hey!
    I tried this code, connections ,I also included the LCD library mentioned but then I am getting this error. Kindly get back ASAP!
    Thanks:)

    Screenshot (487).png
    0
    BagasA10
    BagasA10

    Answer 2 years ago

    Try
    lcd.init();

    0
    SudharsanS9
    SudharsanS9

    2 years ago

    What library should I include?

    0
    ramonblack1987
    ramonblack1987

    2 years ago

    1.//**************Ejemplo para Placa NodeMcu V3 Lolin Version 0.1*****************

    // By Godbad , Colombia

    #include <Wire.h> // Libreria para configurar los puertos Base

    #include <LiquidCrystal_I2C.h> //Libreria para manejar LCD

    LiquidCrystal_I2C lcd(0x27, 16, 2); // Protocolo 0x27 para este tipo de LCD, 16 para la cantidada de caracteres por linea , cantidad de Lineas en el LCD que son 2

    /*

    Ejemplo de nuestro LCD

    X|X|X|X|X|X|X|X|X|X|X|X|X|X|X|X

    X|X|X|X|X|X|X|X|X|X|X|X|X|X|X|X

    */

    void setup()

    {

    pinMode(2, OUTPUT);

    Wire.begin(D2, D1); // D1 = SCL | D2 = SDA

    lcd.init(); // Iniciamos el LCD

    lcd.backlight(); // Prendemos la Iluminacion del LCD

    lcd.clear();

    }

    void loop()

    {

    lcd.clear();

    digitalWrite(2, LOW);

    delay(1000);

    digitalWrite(2, HIGH);

    delay(1000);

    lcd.setCursor(0, 0); // Cursor0 , Linea0

    lcd.print("Linea1");

    lcd.setCursor(0, 1); // Cursor0 , Linea1

    lcd.print("Linea2");

    delay(1000);

    }

    0
    c_lyric
    c_lyric

    2 years ago

    work find, ,but for the 5V power , I use the VU pin ( 5V ) and not Vin ( 0.3v for me plugged on usb )

    0
    AlistairO
    AlistairO

    Question 2 years ago

    What if I'm using PCF8574 at pin D1 and D2 with address 0x20? Can I use pin D3 and D4 for LCD? If so, what address should I use?

    0
    DanielS1086
    DanielS1086

    2 years ago

    How can I go for the buttom line to write another thing? Thanks ;)

    0
    YoussefD12
    YoussefD12

    3 years ago

    If I didn't do a hack, the usual wiring schematic would be like:

    SDA (LCD) →TTL converter from 5V to 3.3V → D2.

    SCL (LCD) → TTL converter from 5V to 3.3V → D1.

    Vcc (LCD) → 5V (of another source).

    Gnd (LCD) → Gnd (of the same other source).

    Do you agree?

    0
    YoussefD12
    YoussefD12

    3 years ago

    What if I wanted to power the NodeMCU (I have ver 3 by the way) from 3.3V and Gnd, will NodeMCU Vin still work if connected to LCD Vcc pin?

    Thanks anyway.

    0
    YoussefD12
    YoussefD12

    Reply 3 years ago

    Would it be possible to use VU pin instead of Vin?

    0
    Swansong
    Swansong

    4 years ago

    Thanks for sharing :)