ESP8266 NodeMCU Internet Clock with ST7735 TFT

This post shows how to implement internet clock using ESP8266 NodeMCU Wi-Fi board where time and date are displayed on ST7735 TFT display.
The ST7735 TFT is a color display with resolution of 128×160 pixel, it communicates with the master device using SPI protocol.
TFT: Thin-Film Transistor
SPI: Serial Peripheral Interface

To see how to interface the NodeMCU board with the ST7735 TFT display, visit this post:
Interfacing ESP8266 NodeMCU with ST7735 TFT

Hardware Required:

  • ESP8266 NodeMCU board
  • ST7735 TFT display module
  • micro USB cable (for programming and powering the circuit)
  • Breadboard
  • Jumper wires

NodeMCU Internet clock with ST7735 TFT circuit:
Project circuit schematic diagram is shown below.

ESP8266 NodeMCU ST7735S TFT display

The ST7735S shown in project circuit diagram has 8 pins: (from right to left): RST (reset), CE (chip enable), DC (or D/C: data/command), DIN (data in), CLK (clock), VCC, BL (back light) and Gnd (ground).

The ST7735 display is connected to the NodeMCU board as follows:
RST pin is connected to D4 (ESP8266EX GPIO2),
CS pin is connected to D3 (ESP8266EX GPIO0),
D/C pin is connected to D2 (ESP8266EX GPIO4),
DIN (MOSI) pin is connected to D7 (ESP8266EX GPIO13),
CLK (SCK) pin is connected to D5 (ESP8266EX GPIO14),
VCC and BL are connected to pin 3V3,
GND is connected to pin GND of the NodeMCU board.

Pins D5 (GPIO14) and D7 (GPIO13) are hardware SPI module pins of the ESP8266EX microcontroller respectively for SCK (serial clock) and MOSI (master-out slave-in).

NodeMCU Internet clock with ST7735 TFT circuit:
The following Arduino code requires two libraries from Adafruit Industries:
The first library is a driver for the ST7735 TFT display which can be installed from Arduino IDE library manager (Sketch —> Include Library —> Manage Libraries …, in the search box write “st7735” and install the one from Adafruit).

The second library is Adafruit graphics library which can be installed also from Arduino IDE library manager.

Both libraries can be installed manually, first download them from the following 2 links:
Adafruit ST7735 TFT library    —->  direct link
Adafruit graphics 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 file.

The other library is NTPClient, this library connects the ESP8266 WiFi to a time server, this server sends time information to the module. NTP: Network Time Protocol.
NTPClient Library   —   direct link

The last one is Arduino Time library, this library converts Unix timestamp (Unix epoch) into: seconds, minutes, hours, day of the week, day, month and year. The Unix epoch is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT).
Basically the time server sends time in Unix epoch format which needs to be converted, this library does all the job. Download links are below:
Arduino Time Library   —   direct link

Hints:
All the used libraries are included in the Arduino code as shown below:

The connection of ST7735 TFT display with the NodeMCU is as shown below where the display is connected to hardware SPI module of the NodeMCU (pins: SCK and MOSI):

The NTPClient library is configured to get time information (Unix epoch) from the server time.nist.gov (GMT time) and an offset of 1 hour ( ==> GMT + 1 time zone) which is equal to 3600 seconds, configuration line is below:
NTPClient timeClient(ntpUDP, “time.nist.gov”, 3600, 60000);

Full Arduino Code:

ESP8266 NodeMCU ST7735 TFT internet clock

Leave a Reply

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