ESP8266 NodeMCU with DS3231 RTC and Nokia 5110 LCD

This tutorial shows how to make a simple digital real time clock using ESP8266 NodeMCU board and DS3231 RTC module where time & date can be set with two push buttons connected to the NodeMCU and they are printed on Nokia 5110 LCD screen (84×48 pixel).
The DS3231 temperature is also printed on the Nokia LCD with resolution of 0.25°C (the DS3231 IC has a built-in temperature sensor).

To see how to interface NodeMCU board with Nokia 5110 LCD, visit this post:
Interfacing ESP8266 NodeMCU with Nokia 5110 LCD

Hardware Required:

  • NodeMCU development board
  • Nokia 5110 LCD module
  • DS3231 module   —->  DS3231 datasheet
  • 2 x push button
  • 3V coin cell battery
  • Micro USB cable (for programming and powering the whole circuit)
  • Breadboard
  • Jumper wires

NodeMCU with DS3231 and Nokia 5110 LCD circuit:
The image below shows project circuit schematic diagram.

The Nokia 5110 LCD which is shown in the circuit diagram has 8 pins (from left to right): RST (reset), CE (chip enable), DC (or D/C: data/command), Din (data in), Clk (clock), VCC (3.3V), BL (back light) and Gnd (ground).

ESP8266 NodeMCU DS3231 Nokia 5110 LCD

The Nokia 5110 LCD is connected to the NodeMCU board as follows:
RST (reset) pin is connected to pin D0 (ESP8266EX GPIO16),
CE (chip enable) pin is connected to pin D1 (ESP8266EX GPIO5),
DC (data/command) pin is connected to pin D2 (ESP8266EX GPIO4),
DIN (data in)  pin is connected to pin D3 (ESP8266EX GPIO0),
CLK (clock) pin is connected to pin D4 (ESP8266EX GPIO2),
VCC and BL are connected to pin 3V3,
GND is connected to pin GND.

The DS3231 RTC module SCL (serial clock) and SDA (serial data) pins are respectively connected to NodeMCU pins D5 and D6.

The two push buttons which are connected to NodeMCU pins D7 and D8 are for setting time & date of the clock. They are connected to NodeMCU pins D7 and D8.

NodeMCU real time clock with set buttons using DS3231 and Nokia LCD

NodeMCU with DS3231 and Nokia 5110 LCD code:
The following Arduino code requires 3 libraries from Adafruit Industries:
The first library is a driver for the Nokia 5110 LCD (PCD8544 controller), download link is below:
Adafruit Nokia 5110 LCD library

The 2nd library is Adafruit graphics library which can be downloaded from the following link
Adafruit graphics library             —->  direct link

The third library is real time clock library (for DS3231), download link is below:
Adafruit RTC library                   —->  direct link

After the download, go to Arduino IDE —> Sketch —> Include Library —> Add .ZIP Library … and browse for the .zip file (previously downloaded).
The same thing for the other library files.

In the Arduino code the previous 3 libraries (and wire library) are included as shown below:

The two push buttons:

Functions used in the code:
bool debounce (): this function is for button B1 debounce, returns 1 if button is debounced.

void RTC_display(): prints day of the week, date and time on the display.

byte edit(byte parameter): this function is for setting the real time clock, returns the edited parameter.

Rest of code is described through comments.

Full Arduino code:

The video below shows my hardware circuit test:

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.