Introduction: Interfacing LCD 20X4 Display to Nodemcu
I decided to share this as I've been facing difficulties with my previous task before, I tried to interface Graphic(128x64) LCD with Nodemcu but to no avail, I failed. I figure out that this must be something to do with the library(Library for graphic LCD is different from common LCD), Seems like the current existing library doesn't suit GLCD interfacing nodemcu,really hope they come out with the "suitable library" soon. I wanted to give a try but I'm in time-constrain so I made a decision to change from graphic LCD to Bluebacklight 20x4 LCD. I thought this going to be easy as the features quite similar to 16x2 LCD but I was wrong again. Thus, start of my try-n-error journey to make this work out.
Interfacing any LCD with Arduino Uno is easy, you can find many tutorials available. There are also tutorial for Interfacing LCD with NodeMCU available,some are using "I2C expender" of "Shift register" and some others use "I2C LCD adapter" but seems like not all these tutorial compatible and some are 'outdated', they might be using different or old library, I get an error once like this : "Error compiling for board NodeMCU 1.0 (ESP-12E Module)", so I change to different library. Done compiling but with a warning : "WARNING: library LiquidCrystal_I2C-1.1.2 claims to run on (avr) architecture(s) and may be incompatible with your current board which runs on (esp8266) architecture(s)", I gave it a try anyway, upload to my board then Success!
Step 1: Upload Library Into Arduino Libraries
Before start, makesure you already installed the library for NodeMCU, if not you can follow this step here. After that don't forget to download and install your LiquidCrystal_I2C library for your LCD too.
Attached here is the zip file of the LiquidCrystal_I2C library that I've been using for this tutorial. I don't remember which website I downloaded it from but credit to the owner.
notes: this is the file that come with the warning I mentioned earlier. But I have no problem uploading the code to my NodeMCU board.
Attachments
Step 2: Connect Your Pin
I'm connecting LCD display to NodeMCU by using I2C LCD serial adapter, from 8 pin of the LCD to 4 pin of the adapter. This is very convenient as NodeMCU is small and we want to limit the usage of pin on that board. I'm using pin D1, D2, Vin and Gnd of the NodeMCU. The connection to the LCD:
Vin = VCC
Gnd = Gnd
D1 = SDA
D2 = SCL
Very straightforward.
Step 3: Upload Code and Run
Copy the code I attached here, and run. Make sure you have selected the Alter the code to your like. Good luck.
May this little tutorial helpful to you. If have any inquiry, don't hesitate to comment.