Close Menu
  • Articles
    • Learn Electronics
    • Product Review
    • Tech Articles
  • Electronics Circuits
    • 555 Timer Projects
    • Op-Amp Circuits
    • Power Electronics
  • Microcontrollers
    • Arduino Projects
    • STM32 Projects
    • AMB82-Mini IoT AI Camera
    • BLE Projects
  • IoT Projects
    • ESP8266 Projects
    • ESP32 Projects
    • ESP32 MicroPython
    • ESP32-CAM Projects
    • LoRa/LoRaWAN Projects
  • Raspberry Pi
    • Raspberry Pi Projects
    • Raspberry Pi Pico Projects
    • Raspberry Pi Pico W Projects
  • Electronics Calculator
Facebook X (Twitter) Instagram
  • About Us
  • Disclaimer
  • Privacy Policy
  • Contact Us
  • Advertise With Us
Facebook X (Twitter) Instagram Pinterest YouTube LinkedIn
How To Electronics
  • Articles
    • Learn Electronics
    • Product Review
    • Tech Articles
  • Electronics Circuits
    • 555 Timer Projects
    • Op-Amp Circuits
    • Power Electronics
  • Microcontrollers
    • Arduino Projects
    • STM32 Projects
    • AMB82-Mini IoT AI Camera
    • BLE Projects
  • IoT Projects
    • ESP8266 Projects
    • ESP32 Projects
    • ESP32 MicroPython
    • ESP32-CAM Projects
    • LoRa/LoRaWAN Projects
  • Raspberry Pi
    • Raspberry Pi Projects
    • Raspberry Pi Pico Projects
    • Raspberry Pi Pico W Projects
  • Electronics Calculator
How To Electronics
Home » IoT Based Analog/Digital OLED Clock using NodeMCU
ESP8266 Projects IoT Projects

IoT Based Analog/Digital OLED Clock using NodeMCU

Mamtaz AlamBy Mamtaz AlamUpdated:May 26, 20234 Comments3 Mins Read
Share Facebook Twitter LinkedIn Telegram Reddit WhatsApp
IOT Based Analog Digital OLED Clock using NodeMCU
Share
Facebook Twitter LinkedIn Pinterest Email Reddit Telegram WhatsApp

IoT Based Analog/Digital OLED Clock using NodeMCU:

In this post, we will learn how to make IoT Based Analog/Digital OLED Clock using NodeMCU. There is no need for any RTC Module like DS1307 or DS3231. Simply the time and date will be downloaded from an online server. We can display the downloaded time either in Analog form or in digital form.

You can check our earlier post related to Clock:
1. Arduino & DS3231 Based Real Time Clock (RTC) & Temperature Monitor
2. Arduino DS3231 Based Real Time Clock with Alarm & Temperature Monitor
3. Arduino GPS Clock System



Components Required

S.N.Components NameQuantityPurchase Links
1NodeMCU ESP8266 Board1Amazon | AliExpress
20.96" I2C OLED Display1Amazon | AliExpress
3Connecting Wires10Amazon | AliExpress
4Breadboard1Amazon | AliExpress

0.96″ I2C OLED Display:

This is a 0.96 inch blue OLED display module. The display module can be interfaced with any microcontroller using SPI/IIC protocols. It is having a resolution of 128×64. The package includes display board, display,4 pin male header pre-soldered to board.

ECG Display using Pulse Sensor with OLED & Arduino

OLED (Organic Light-Emitting Diode) is a self light-emitting technology composed of a thin, multi-layered organic film placed between an anode and cathode. In contrast to LCD technology, OLED does not require a backlight. OLED possesses high application potential for virtually all types of displays and is regarded as the ultimate technology for the next generation of flat-panel displays.


Circuit Diagram & Connection:

With the help of the below Circuit diagram, you can make IoT Based Analog/Digital OLED Clock using NodeMCU. So assemble the circuit as shown in the figure below.

Analog Digital OLED IOT Clock Circuit Diagram

Connect the SCL Pin of OLED to the D1 Pin of NodeMCU.
Also, Connect the SDA pin of OLED to D2 Pin of NodeMCU.
Connect 3.3V & GND pin of OLED to 3.3V & GND Pin of NodeMCU.</p



Working of the Project:

The Arduino IDE is used to develop a sketch that accesses an NPT time server to accurately set the date and time. The date and time are then displayed on an OLED display and also via a web browser accessing the ESP8266 webserver. The web page allows the setting of options like Time Zone, 24-hour clock, daylight savings and a variable to control the time server update interval. The web page uses AJAX to update the time without reloading the entire web page.

The NTPClient library connects the ESP8266 WiFi to a time server, this server sends time information to the module. NTP: Network Time Protocol.

The last one is the 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.

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, the configuration line is below:

C++
1
configTime(timezone, dst, "pool.ntp.org","time.nist.gov");


Source Code/Program for Analog OLED Clock:

analog clock nodemcu

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#include <ESP8266WiFi.h>
#include <time.h>
 
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
 
#define OLED_RESET LED_BUILTIN //4
Adafruit_SSD1306 display(OLED_RESET);
 
const char* ssid = "AlexHome";
const char* password = "hngzhowxiantan";
 
int ledPin = 13;
 
int timezone = 7 * 3600;
int dst = 0;
 
#if (SSD1306_LCDHEIGHT != 64)
#error("Height incorrect, please fix Adafruit_SSD1306.h!");
#endif
 
void setup() {
 
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
 
// Clear the buffer.
display.clearDisplay();
display.display();
 
pinMode(ledPin,OUTPUT);
digitalWrite(ledPin,LOW);
 
Serial.begin(115200);
 
display.setTextSize(1);
display.setTextColor(WHITE);
 
display.setCursor(0,0);
display.println("Wifi connecting to ");
display.println( ssid );
 
WiFi.begin(ssid,password);
 
display.println("\nConnecting");
 
display.display();
 
while( WiFi.status() != WL_CONNECTED ){
delay(500);
display.print(".");
display.display();
}
 
// Clear the buffer.
display.clearDisplay();
display.display();
display.setCursor(0,0);
 
display.println("Wifi Connected!");
display.print("IP:");
display.println(WiFi.localIP() );
 
display.display();
 
configTime(timezone, dst, "pool.ntp.org","time.nist.gov");
display.println("\nWaiting for NTP...");
 
while(!time(nullptr)){
Serial.print("*");
 
delay(1000);
}
display.println("\nTime response....OK");
display.display();
delay(1000);
 
display.clearDisplay();
display.display();
}
 
void loop() {
 
time_t now = time(nullptr);
struct tm* p_tm = localtime(&now);
int r = 35;
// Now draw the clock face
 
display.drawCircle(display.width()/2, display.height()/2, 2, WHITE);
//
//hour ticks
for( int z=0; z < 360;z= z + 30 ){
//Begin at 0° and stop at 360°
float angle = z ;
 
angle=(angle/57.29577951) ; //Convert degrees to radians
int x2=(64+(sin(angle)*r));
int y2=(32-(cos(angle)*r));
int x3=(64+(sin(angle)*(r-5)));
int y3=(32-(cos(angle)*(r-5)));
display.drawLine(x2,y2,x3,y3,WHITE);
}
// display second hand
float angle = p_tm->tm_sec*6 ;
angle=(angle/57.29577951) ; //Convert degrees to radians
int x3=(64+(sin(angle)*(r)));
int y3=(32-(cos(angle)*(r)));
display.drawLine(64,32,x3,y3,WHITE);
//
// display minute hand
angle = p_tm->tm_min * 6 ;
angle=(angle/57.29577951) ; //Convert degrees to radians
x3=(64+(sin(angle)*(r-3)));
y3=(32-(cos(angle)*(r-3)));
display.drawLine(64,32,x3,y3,WHITE);
//
// display hour hand
angle = p_tm->tm_hour * 30 + int((p_tm->tm_min / 12) * 6 );
angle=(angle/57.29577951) ; //Convert degrees to radians
x3=(64+(sin(angle)*(r-11)));
y3=(32-(cos(angle)*(r-11)));
display.drawLine(64,32,x3,y3,WHITE);
 
display.setTextSize(1);
display.setCursor((display.width()/2)+10,(display.height()/2) - 3);
display.print(p_tm->tm_mday);
 
// update display with all data
display.display();
delay(100);
display.clearDisplay();
 
}



Source Code/Program for Digital OLED Clock:

digital clock nodemcu oled

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#include <ESP8266WiFi.h>
#include <time.h>
 
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
 
#define OLED_RESET LED_BUILTIN //4
Adafruit_SSD1306 display(OLED_RESET);
 
const char* ssid = "AlexHome";
const char* password = "hngzhowxiantan";
 
int ledPin = 13;
 
int timezone = 7 * 3600;
int dst = 0;
 
#if (SSD1306_LCDHEIGHT != 64)
#error("Height incorrect, please fix Adafruit_SSD1306.h!");
#endif
 
void setup() {
 
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
 
// Clear the buffer.
display.clearDisplay();
display.display();
 
pinMode(ledPin,OUTPUT);
digitalWrite(ledPin,LOW);
 
Serial.begin(115200);
 
display.setTextSize(1);
display.setTextColor(WHITE);
 
display.setCursor(0,0);
display.println("Wifi connecting to ");
display.println( ssid );
 
WiFi.begin(ssid,password);
 
display.println("\nConnecting");
 
display.display();
 
while( WiFi.status() != WL_CONNECTED ){
delay(500);
display.print(".");
display.display();
}
 
// Clear the buffer.
display.clearDisplay();
display.display();
display.setCursor(0,0);
 
display.println("Wifi Connected!");
display.print("IP:");
display.println(WiFi.localIP() );
 
display.display();
 
configTime(timezone, dst, "pool.ntp.org","time.nist.gov");
display.println("\nWaiting for NTP...");
 
while(!time(nullptr)){
Serial.print("*");
 
delay(1000);
}
display.println("\nTime response....OK");
display.display();
delay(1000);
 
display.clearDisplay();
display.display();
}
 
void loop() {
 
time_t now = time(nullptr);
struct tm* p_tm = localtime(&now);
 
Serial.print(p_tm->tm_mday);
Serial.print("/");
Serial.print(p_tm->tm_mon + 1);
Serial.print("/");
Serial.print(p_tm->tm_year + 1900);
 
Serial.print(" ");
 
Serial.print(p_tm->tm_hour);
Serial.print(":");
Serial.print(p_tm->tm_min);
Serial.print(":");
Serial.println(p_tm->tm_sec);
 
// Clear the buffer.
display.clearDisplay();
 
display.setTextSize(3);
display.setTextColor(WHITE);
 
display.setCursor(0,0);
display.print(p_tm->tm_hour);
display.print(":");
if( p_tm->tm_min <10)
display.print("0");
display.print(p_tm->tm_min);
 
display.setTextSize(2);
display.setCursor(90,5);
display.print(".");
if( p_tm->tm_sec <10)
display.print("0");
display.print(p_tm->tm_sec);
 
display.setTextSize(1);
display.setCursor(0,40);
display.print(p_tm->tm_mday);
display.print("/");
display.print(p_tm->tm_mon + 1);
display.print("/");
display.print(p_tm->tm_year + 1900);
 
display.display();
 
delay(1000); // update every 1 sec
 
}


Video Tutorial:

IOT Based Analog/Digital OLED Internet Clock || IOT Real Time Clock
Watch this video on YouTube.

You can check this project here as well: IoT Internet Clock with ESP32 & LCD Display using NTP Client

Share. Facebook Twitter Pinterest LinkedIn Tumblr Email Reddit Telegram WhatsApp
Previous ArticleAutomatic LED Blinking Circuit using 555 Timer IC – LED Flasher
Next Article Touch Detector using Arduino TTP223 Capacitive Touch Sensor

Related Posts

ESP32 Fingerprint Attendance System with Live Web Dashboard

ESP32 Fingerprint Attendance System with Live Web Dashboard

Updated:June 21, 2026
IoT Based PM & Air Quality Monitoring System using ESP32

IoT Based PM & Air Quality Monitoring System using ESP32

Updated:June 14, 2026
DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

Updated:May 10, 20262K
IoT Activity Tracker with ESP32 & Accelerometer Gyroscope

IoT Activity Tracker with ESP32 & Accelerometer/Gyroscope

Updated:May 2, 2026

ESP32 IoT Vehicle Motion Analyzer with MPU6050 & LIS3MDL

Updated:April 27, 20261K
High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

Updated:April 27, 20262K
View 4 Comments

4 Comments

  1. Shijil Thachilodi on May 25, 2019 9:12 PM

    hi, can you help to add a relay based on time with this script ?

    Reply
  2. Ulrich Engel on November 23, 2020 3:23 PM

    Hi, fine tutorial. I use the analog clock.
    But I get the error:
    #error (“Height incorrect, please fix Adafruit_SSD1306.h!”);

    I use adafruit_ssd1306 version 2.4.1

    What version do you use.

    Thanks

    Reply
  3. Stephen Carey on December 14, 2020 7:47 PM

    Dear Mr Alam . . . . I am making a few Analog Watches for famliy members for Christmas presents. In less than an hour I have an ESP8266 programmed, conncts to my internest fast . . . and displaying the clock face . . . after 20 seconds is connected to the time server for GMT (here in the UK) . . . . . but the image of the clock and date is upside down! How can I invert it in the software sketch???
    Your help please . . . Thank you.

    Steve/G4MJW

    Reply
  4. Jolo55 on January 3, 2021 4:30 AM

    Trash that shketch contains many errors!

    Reply

CommentsCancel reply

Latest Posts
ESP32 Fingerprint Attendance System with Live Web Dashboard

ESP32 Fingerprint Attendance System with Live Web Dashboard

June 21, 2026
IoT Based PM & Air Quality Monitoring System using ESP32

IoT Based PM & Air Quality Monitoring System using ESP32

June 14, 2026
DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

May 10, 2026
IoT Activity Tracker with ESP32 & Accelerometer Gyroscope

IoT Activity Tracker with ESP32 & Accelerometer/Gyroscope

May 2, 2026
A Guide to Sourcing Obsolete ICs for Vintage Projects

Beyond AliExpress: A Guide to Sourcing Obsolete ICs for Vintage Projects

April 21, 2026

ESP32 IoT Vehicle Motion Analyzer with MPU6050 & LIS3MDL

April 27, 2026
Building a Smart Sensor Node with a BLE Microcontroller

Building a Smart Sensor Node with a BLE Microcontroller

February 26, 2026
High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

April 27, 2026
Top Posts & Pages
  • ESP32 Fingerprint Attendance System with Live Web Dashboard
    ESP32 Fingerprint Attendance System with Live Web Dashboard
  • IoT AC Energy Meter with PZEM-004T & ESP32 WebServer
    IoT AC Energy Meter with PZEM-004T & ESP32 WebServer
  • 12V DC to 220V AC Inverter Circuit & PCB
    12V DC to 220V AC Inverter Circuit & PCB
  • LD2410 Sensor with ESP32 - Human Presence Detection
    LD2410 Sensor with ESP32 - Human Presence Detection
  • IoT Based ECG Monitoring with AD8232 ECG Sensor & ESP32
    IoT Based ECG Monitoring with AD8232 ECG Sensor & ESP32
  • Half Wave Rectifier Basics, Circuit, Working & Applications
    Half Wave Rectifier Basics, Circuit, Working & Applications
  • How to use INA226 DC Current Sensor with Arduino
    How to use INA226 DC Current Sensor with Arduino
  • Designing of MPPT Solar Charge Controller using Arduino
    Designing of MPPT Solar Charge Controller using Arduino
Categories
  • Arduino Projects (197)
  • Articles (60)
    • Learn Electronics (19)
    • Product Review (15)
    • Tech Articles (28)
  • Electronics Circuits (46)
    • 555 Timer Projects (21)
    • Op-Amp Circuits (7)
    • Power Electronics (13)
  • IoT Projects (205)
    • ESP32 MicroPython (7)
    • ESP32 Projects (82)
    • ESP32-CAM Projects (15)
    • ESP8266 Projects (76)
    • LoRa/LoRaWAN Projects (22)
  • Microcontrollers (38)
    • AMB82-Mini IoT AI Camera (4)
    • BLE Projects (18)
    • STM32 Projects (19)
  • Raspberry Pi (93)
    • Raspberry Pi Pico Projects (57)
    • Raspberry Pi Pico W Projects (12)
    • Raspberry Pi Projects (24)
Follow Us
  • Facebook
  • Twitter
  • Pinterest
  • Instagram
  • YouTube
About Us

“‘How to Electronics’ is a vibrant community for electronics enthusiasts and professionals. We deliver latest insights in areas such as Embedded Systems, Power Electronics, AI, IoT, and Robotics. Our goal is to stimulate innovation and provide practical solutions for students, organizations, and industries. Join us to transform learning into a joyful journey of discovery and innovation.

Copyright © How To Electronics. All rights reserved.
  • About Us
  • Disclaimer
  • Privacy Policy
  • Contact Us
  • Advertise With Us

Type above and press Enter to search. Press Esc to cancel.

Ad Blocker Enabled!
Ad Blocker Enabled!
Looks like you're using an ad blocker. Please allow ads on our site. We rely on advertising to help fund our site.