Menu

Sunday, October 25, 2026

ESP8266 and 16x4 Character LCD Example

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.

 

ESP8266 and 16x4 Character LCD Example
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 


  1. // include the library code:
  2. #include <LiquidCrystal.h>

  3. // initialize the library by associating any needed LCD interface pin
  4. // with the arduino pin number it is connected to
  5. const int rs = 16, en = 5, d4 = 4, d5 = 0, d6 = 2, d7 = 14;
  6. LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

  7. void setup() {
  8. // set up the LCD's number of columns and rows:
  9. lcd.begin(16, 4);
  10. // Print a message to the LCD.
  11. lcd.print("hello, world!");
  12. lcd.setCursor(0, 1);
  13. lcd.print("ESP8266 NodeMCU");
  14. lcd.setCursor(0, 2);
  15. lcd.print("LCD Programming");
  16. lcd.setCursor(0, 3);
  17. lcd.print("Using Arduino");
  18. delay(5000);
  19. lcd.clear();
  20. lcd.print("ESP8266 Running:");
  21. }

  22. void loop() {
  23. // set the cursor to column 0, line 1
  24. // (note: line 1 is the second row, since counting begins with 0):
  25. lcd.setCursor(0, 1);
  26. // print the number of seconds since reset:
  27. lcd.print(millis() / 1000);
  28. lcd.setCursor(0,2);
  29. lcd.print("Seconds");
  30. delay(500);
  31. }


Schematic 

I draw this circuit using easyEDA. 

ESP8266 and 16x4 Character LCD Example
Schematic

Testing using Arduino Module

I tested it using my DIY NodeMCU TWI board. 

ESP8266 and 16x4 Character LCD Example
My DIY NodeMCU TWI board

ESP8266 and 16x4 Character LCD Example
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


  1. // include the library code:
  2. #include <LiquidCrystal.h>
  3. #include <ESP8266WiFi.h>

  4. const char* ssid = "your-ssid";
  5. const char* password = "your-password";
  6. // Create an instance of the server
  7. // specify the port to listen on as an argument
  8. WiFiServer server(80);

  9. // initialize the library by associating any needed LCD interface pin
  10. // with the arduino pin number it is connected to
  11. const int rs = 16, en = 5, d4 = 4, d5 = 0, d6 = 2, d7 = 14;
  12. LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

  13. void setup() {
  14. // set up the LCD's number of columns and rows:
  15. lcd.begin(16, 4);
  16. // Print a message to the LCD.
  17. lcd.print("ESP8266 nodeMCU");
  18. lcd.setCursor(0, 1);
  19. lcd.print("LiquidCrystal");
  20. lcd.setCursor(0, 2);
  21. lcd.print("LCD Example");
  22. lcd.setCursor(0, 3);
  23. lcd.print("and WiFi Info");
  24. delay(5000);
  25. Serial.begin(115200);
  26. lcd.clear();
  27. lcd.setCursor(0,0);
  28. lcd.print("Connecting to");
  29. lcd.setCursor(0,1);
  30. lcd.print("Home Router");
  31. // Connect to WiFi network
  32. Serial.println();
  33. Serial.println();
  34. WiFi.mode(WIFI_STA);
  35. WiFi.begin(ssid, password);
  36. while (WiFi.status() != WL_CONNECTED) {
  37. delay(500);
  38. Serial.print(F("."));
  39. }
  40. Serial.println();
  41. Serial.println(F("WiFi connected"));

  42. // Start the server
  43. server.begin();
  44. Serial.println(F("Server started"));

  45. // Print the IP address
  46. Serial.println(WiFi.localIP());
  47. delay(5000);
  48. lcd.clear();
  49. lcd.setCursor(0,0);
  50. lcd.print("Connected IP");
  51. lcd.setCursor(0,1);
  52. lcd.print(WiFi.localIP());
  53. }

  54. void loop() {
  55. // set the cursor to column 0, line 1
  56. // (note: line 1 is the second row, since counting begins with 0):
  57. lcd.setCursor(0, 2);
  58. // print the number of seconds since reset:
  59. lcd.print(millis() / 1000);
  60. lcd.setCursor(0,3);
  61. lcd.print("Seconds");
  62. delay(500);
  63. }


Pictures

I tested it using my DIY NodeMCU TWI board. 

 

ESP8266 and 16x4 Character LCD Example
My DIY NodeMCU TWI board

ESP8266 and 16x4 Character LCD Example
my DIY NodeMCU TWI board

ESP8266 and 16x4 Character LCD Example
My DIY NodeMCU TWI board

 

 






No comments:

Post a Comment

Search This Blog

Electronics and Programming Tutorials

DIY Electronic Projects And Instruments

Labels

23K256 (1) 24C16B (2) 25AA010A (2) 8051 (7) 93AA46B (1) ADC (40) Analog Comparator (1) Arduino (17) ARM (32) AT89C52 (7) ATMega32 (59) ATMega644P (27) AVR (88) AVR PCB (2) Bootloader (1) CCS PICC (31) Change Notify Interrupt (CNI) (2) DAC (2) DHT11 (5) Display (159) Distance Sensor (3) dot matrix (1) ds1307 (10) DS18B20 (6) ds3231 (2) ds3232 (2) dsPIC (16) dsPIC30F1010 (3) dsPIC30F2010 (15) EEPROM (5) Environment Sensor (6) ESP-12E (3) ESP32 (1) esp8266 (4) Graphical LCD (3) HD44780 (14) I2C (40) ILI9341 (1) Input/Output (85) Interrupt (22) IoT (2) IoT PCB (1) Keil (5) Keypad (16) KS0108 (3) LCD (90) LM35 (4) Master/Slave (2) MAX7221 (1) MCP23017 (8) MCP23S17 (7) MCP4921 (1) MCP4922 (2) Meter (3) MikroC (2) MikroC ARM (1) MikroC dsPIC (11) MikroC PIC (2) Module PCB (2) Motor (15) MPLABX (73) Nokia 5110 LCD (5) OLED (2) One-Wire (7) Oscillator (8) PCB (13) PCD8544 (3) PCF8574 (13) PIC (122) PIC12F (3) PIC16 (105) PIC16F628A (3) PIC16F630 (2) PIC16F716 (4) PIC16F818 (11) PIC16F818/819 (3) PIC16F84A (16) PIC16F876A (2) PIC16F877A (9) PIC16F88 (2) PIC16F887 (60) PIC18 (19) PIC18F1220 (5) PIC18F2550 (5) PIC18F4550 (14) PICKit2 (1) PICMicro PCB (4) Pin Change Interrupt (1) PLL (1) PWM (12) RTC (14) SBN0064G (1) Sensor (15) SH1106 (4) Shift Register (15) Shift Registers (19) SN74HC595N (9) Software SPI (1) Software TWI (3) SPI (44) sprinf (3) ST7735 (1) STM32 (29) STM32 Black Pill (1) STM32 Blue Pill (12) STM32 HAL (23) STM32CubeIDE (32) STM32F103C8T6 (9) STM32F103R6 (18) STM32F401CCU6 (1) SysTick (7) temperature sensor (15) TFT (1) TG12864A (1) Thermometer (22) Timer/Counter (32) TM1637 (2) twi (11) UART (11) Ultrasonic (4) Voltmeter (7) WDT (1) Web Server (1) Wi-Fi (2) XC16 (2) XC8 (96)