Overview
Using a character display with a micro-controller is simple for most of students in embedded programming. A parallel port HD44780 based character LCD is popular among students, electronic hobbyists, and engineers. This 8-bit parallel port interface LCD commonly uses its 4-bit data transfer mode to save the number of I/O, and reducing complexity in wiring. However in programming section, the use have to send data or command twice. That's not a problem in programming.
The HD44780 base character LCD are widely used and available at very low cost, around 1USD. It has different color, dimensions and display sizes. There are a lot of replacement display controllers for this conventional chip. They are very low cost and lower power consumption.
ESP8266 NodeMCU Programming and Interfacing with a 16x4 LCD
Using Arduino IDE to to program and interface with any modules is common today since it has a lot of libraries and community supports. Arduino modules are available at very low cost and very easy to test. Similarly, we don't need to do manual C/C++ coding for a 16x4 LCD module. There are a lot of reliable, free and easy to use libraries of this stuff.
Arduino LiquidCrystal Library
The Liquid Crystal is compatible with ESP8266 MCU.
![]() |
| LiquidCrystal HelloWorld Example |
I use the LiquidCrystal library installed in my Arduino IDE. To test it, open one example - for instance the HelloWorld.ino .
I opened and modified this example to work with my old 16x4 character LCD.
NodeMCU Arduino Source Code
- // include the library code:
- #include <LiquidCrystal.h>
- // initialize the library by associating any needed LCD interface pin
- // with the arduino pin number it is connected to
- const int rs = 16, en = 5, d4 = 4, d5 = 0, d6 = 2, d7 = 14;
- LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
- void setup() {
- // set up the LCD's number of columns and rows:
- lcd.begin(16, 4);
- // Print a message to the LCD.
- lcd.print("hello, world!");
- lcd.setCursor(0, 1);
- lcd.print("ESP8266 NodeMCU");
- lcd.setCursor(0, 2);
- lcd.print("LCD Programming");
- lcd.setCursor(0, 3);
- lcd.print("Using Arduino");
- delay(5000);
- lcd.clear();
- lcd.print("ESP8266 Running:");
- }
- void loop() {
- // set the cursor to column 0, line 1
- // (note: line 1 is the second row, since counting begins with 0):
- lcd.setCursor(0, 1);
- // print the number of seconds since reset:
- lcd.print(millis() / 1000);
- lcd.setCursor(0,2);
- lcd.print("Seconds");
- delay(500);
- }
Schematic
I draw this circuit using easyEDA.
![]() |
| Schematic |
Testing using Arduino Module
I tested it using my DIY NodeMCU TWI board.
![]() |
| My DIY NodeMCU TWI board |
![]() |
| My DIY NodeMCU TWI board |
WiFi Connection Information
Here I use the ESP8266 WiFi feature to show connection status to home Wi-Fi router. It will show the IP address assigned by the router after a succeed wireless connection.
Arduino Source Code
- // include the library code:
- #include <LiquidCrystal.h>
- #include <ESP8266WiFi.h>
- const char* ssid = "your-ssid";
- const char* password = "your-password";
- // Create an instance of the server
- // specify the port to listen on as an argument
- WiFiServer server(80);
- // initialize the library by associating any needed LCD interface pin
- // with the arduino pin number it is connected to
- const int rs = 16, en = 5, d4 = 4, d5 = 0, d6 = 2, d7 = 14;
- LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
- void setup() {
- // set up the LCD's number of columns and rows:
- lcd.begin(16, 4);
- // Print a message to the LCD.
- lcd.print("ESP8266 nodeMCU");
- lcd.setCursor(0, 1);
- lcd.print("LiquidCrystal");
- lcd.setCursor(0, 2);
- lcd.print("LCD Example");
- lcd.setCursor(0, 3);
- lcd.print("and WiFi Info");
- delay(5000);
- Serial.begin(115200);
-
- lcd.clear();
- lcd.setCursor(0,0);
- lcd.print("Connecting to");
- lcd.setCursor(0,1);
- lcd.print("Home Router");
- // Connect to WiFi network
- Serial.println();
- Serial.println();
-
- WiFi.mode(WIFI_STA);
- WiFi.begin(ssid, password);
- while (WiFi.status() != WL_CONNECTED) {
- delay(500);
- Serial.print(F("."));
- }
- Serial.println();
- Serial.println(F("WiFi connected"));
- // Start the server
- server.begin();
- Serial.println(F("Server started"));
- // Print the IP address
- Serial.println(WiFi.localIP());
- delay(5000);
- lcd.clear();
- lcd.setCursor(0,0);
- lcd.print("Connected IP");
- lcd.setCursor(0,1);
- lcd.print(WiFi.localIP());
- }
- void loop() {
- // set the cursor to column 0, line 1
- // (note: line 1 is the second row, since counting begins with 0):
- lcd.setCursor(0, 2);
- // print the number of seconds since reset:
- lcd.print(millis() / 1000);
- lcd.setCursor(0,3);
- lcd.print("Seconds");
- delay(500);
- }
Pictures
I tested it using my DIY NodeMCU TWI board.
![]() |
| My DIY NodeMCU TWI board |
![]() |
| my DIY NodeMCU TWI board |
![]() |
| My DIY NodeMCU TWI board |







No comments:
Post a Comment