I2C LCD on NodeMCU V2 With Arduino IDE

18,080

6

9

Published

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!

Share

    Recommendations

    • Oil Contest

      Oil Contest
    • Creative Misuse Contest

      Creative Misuse Contest
    • Clocks Contest

      Clocks Contest

    9 Discussions

    What library should I include?

    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);

    }

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

    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?

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

    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?

    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.

    1 reply

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

    Thanks for sharing :)