SlideShare a Scribd company logo
Internet ofThings
Getting Date & Time From NTP Server
With ESP8266 NodeMCU
Eng. Elaf A.Saeed
The Contents
• NTP Server With ESP8266 NodeMCU.
• Getting Day & Time From NTP Server With ESP8266 NodeMCU.
• Getting Current Day and Time from NTP Server.
• Getting Current Date and Time from NTP Server.
Getting Day & Time & date From NTP
Server With ESP8266 NodeMCU
NTP Server With ESP8266 NodeMCU
NTP Server With ESP8266 NodeMCU
(cont.)
• NTP stands for Network Time Protocol and it is a networking protocol for clock
synchronization between computer systems. In other words, it is used to synchronize
computer clock times in a network.
• The protocol can be used to synchronize all networked devices to Coordinated
Universal Time (UTC) within a few milliseconds ( 50 milliseconds over the public
Internet and under 5 milliseconds in a LAN environment).
• Coordinated Universal Time (UTC) is a world-wide time standard, closely related to
GMT (Greenwich Mean Time). UTC does not vary, it is the same world wide.
NTP Server With ESP8266 NodeMCU
(cont.)
❑NTPArchitecture
• NTP uses a hierarchical architecture. Each level in the
hierarchy is known as a stratum.
• At the very top are high-precision timekeeping devices,
such as atomic clocks, GPS or radio clocks, known as
stratum 0 hardware clocks.
• Stratum 1 servers have a direct connection to a stratum 0
hardware clock and therefore have the most accurate time.
• Each stratum in the hierarchy synchronizes to the stratum
above and act as servers for lower stratum computers.
NTP Server With ESP8266 NodeMCU
(cont.)
❑How NTP Works?
• NTP can operate in a number of ways. The most common configuration
is to operate in client-server mode. The basic working principle is as
follows:
1. The client device such as ESP8266 connects to the server using the
User Datagram Protocol (UDP) on port 123.
2. A client then transmits a request packet to a NTP server.
3. In response to this request the NTP server sends a time stamp packet.
4. A time stamp packet contains multiple information like UNIX
timestamp, accuracy, delay or time zone.
5. A client can then parse out current date & time values.
NTP Server With ESP8266 NodeMCU
(cont.)
❑Installing the NTPClient Library
• We’ll use the NTPClient library to get time. In your Arduino IDE, go to
Sketch > Library > Manage Libraries. The Library Manager should open.
• Search for NTPClient and install the library by Fabrice Weinber as shown in
the following image.
Getting Day & Time From NTP Server
With ESP8266 NodeMCU
Getting Day & Time From NTP Server
With ESP8266 NodeMCU
❑NTPClient Library Time Functions
• getDay() – returns an int number that corresponds to the the week day (0 to 6)
starting on Sunday;
• getHours() – returns an int number with the current hour (0 to 23) in 24 hour format;
• getMinutes() – returns an int number with the current minutes (0 to 59);
• getSeconds() – returns an int number with the current second;
• getEpochTime() – returns an unsigned long with the epoch time (number of seconds
that have elapsed since January 1, 1970 (midnight GMT);
• getFormattedTime() – returns a String with the time formatted like HH:MM:SS;
Getting Day & Time From NTP Server
With ESP8266 NodeMCU (cont.)
Getting Current Day and Time from
NTP Server (cont.)
Getting Current Day and Time from
NTP Server (cont.)
Getting Current Date and Time from
NTP Server
❑Function that is used in Code
1. year()➔ Set or read the RTC year value.
Syntax
year(unsigned long year)
2. month() ➔ Set or read the RTC month value.
Syntax
month(unsigned long month)
3. day() ➔ Set or read the RTC day value.
Syntax
day(unsigned long day)
Getting Current Date and Time from
NTP Server (cont.)
❑Function that is used in Code
4. minute() ➔ Set or read the RTC minute value.
Syntax: minute(unsigned long minute)
5. second() ➔ Set or read the RTC second value.
Syntax: second(unsigned long second) .
Getting Current Date and Time from
NTP Server (cont.)
Getting Current Date and Time from
NTP Server (cont.)
Getting Current Date and Time from
NTP Server (cont.)
Getting Current Date and Time from
NTP Server (cont.)
Thanks

More Related Content

PPTX
Economic load dispatch
DOC
SCADA PROJECTS ABSTRACT-Scada for power station substation monitoring and aut...
PPT
application of power electronics
PDF
Engineering Final Year Project Report on "Electrical Safety and Protection of...
PPTX
Study and realization of dc micro-grid for remote areas.
PDF
Mathematical models of electric machines
PDF
Ee 1351 power system analysis
PDF
Modern Control - Lec 02 - Mathematical Modeling of Systems
Economic load dispatch
SCADA PROJECTS ABSTRACT-Scada for power station substation monitoring and aut...
application of power electronics
Engineering Final Year Project Report on "Electrical Safety and Protection of...
Study and realization of dc micro-grid for remote areas.
Mathematical models of electric machines
Ee 1351 power system analysis
Modern Control - Lec 02 - Mathematical Modeling of Systems

What's hot (20)

PPTX
Block Reduction Method
PPTX
Unit 1 Power System Stability
PDF
Modern Control System (BE)
PPT
Block diagram &_overall_transferfunction_of_a_multiloop_control_system
PPT
Transfer Function, Concepts of stability(critical, Absolute & Relative) Poles...
PPTX
33kv substation
PDF
Polar Plot
PPTX
Load flow study
PDF
Log antilog amplifiers by ransher
PPTX
Microgrid Presentation
PPTX
Block diagram Examples
PPTX
DC compound motor ppt
PPTX
Energy & Power Signals |Solved Problems|
PDF
DC motors characteristics, Torque & Speed Equations, Torque -Armature current...
PPT
Design and Construction of DC Motor Speed Controller Using Android.ppt
PPT
Lyapunov stability
PPT
Transfer function and mathematical modeling
PPT
3 reactive power and voltage control
PDF
Plc report
PPTX
Deadbeat Response Design _8th lecture
Block Reduction Method
Unit 1 Power System Stability
Modern Control System (BE)
Block diagram &_overall_transferfunction_of_a_multiloop_control_system
Transfer Function, Concepts of stability(critical, Absolute & Relative) Poles...
33kv substation
Polar Plot
Load flow study
Log antilog amplifiers by ransher
Microgrid Presentation
Block diagram Examples
DC compound motor ppt
Energy & Power Signals |Solved Problems|
DC motors characteristics, Torque & Speed Equations, Torque -Armature current...
Design and Construction of DC Motor Speed Controller Using Android.ppt
Lyapunov stability
Transfer function and mathematical modeling
3 reactive power and voltage control
Plc report
Deadbeat Response Design _8th lecture
Ad

Similar to Getting date and time from ntp server with esp8266 node mcu (20)

PPTX
Seminar
PDF
4 ip services dhcp
PDF
4 ip services dhcp-part b
PDF
4 ip services nat
PPT
Clock synchronization in distributed system
PDF
4 ip services span,rspan
PDF
Whats the Time
PPT
Chapter 10
PPTX
PPTX
PDF
Analyze and Store Logs - RHCSA (RH124).pdf
PDF
𝙳𝙾𝚆𝙽𝙻𝙾𝙰𝙳—Capcut Pro Crack For PC Latest 2025 Version
PDF
Microsoft Office 365 Crack + Product Key Latest | PPT
PDF
Final Cut Pro Crack Version Latest 2025?
PDF
Adobe Photoshop Crack ➔ Secure Download Now
PDF
Microsoft Office 365 Crack Version Free Download 2025
PDF
Microsoft Office 365 Crack Version Free Download 2025
PDF
kernesssssl_timesssssssssssssssssssr.pdf
PPT
Clock Synchronization (Distributed computing)
PDF
Synchronization For High Frequency Trading Networks: A How To Guide
Seminar
4 ip services dhcp
4 ip services dhcp-part b
4 ip services nat
Clock synchronization in distributed system
4 ip services span,rspan
Whats the Time
Chapter 10
Analyze and Store Logs - RHCSA (RH124).pdf
𝙳𝙾𝚆𝙽𝙻𝙾𝙰𝙳—Capcut Pro Crack For PC Latest 2025 Version
Microsoft Office 365 Crack + Product Key Latest | PPT
Final Cut Pro Crack Version Latest 2025?
Adobe Photoshop Crack ➔ Secure Download Now
Microsoft Office 365 Crack Version Free Download 2025
Microsoft Office 365 Crack Version Free Download 2025
kernesssssl_timesssssssssssssssssssr.pdf
Clock Synchronization (Distributed computing)
Synchronization For High Frequency Trading Networks: A How To Guide
Ad

More from Elaf A.Saeed (20)

PDF
IOT NodeMCU - NodeMCU Webserver
PDF
IOT NodeMCU - Ubidots Platform to Turn on LEDs
PDF
IOT NodeMCU - Thinger Platform to Turn on LEDs
PDF
IOT NodeMCU - IFTTT Templet to send SMS
PDF
ESP8266 NodeMCU Server, Client, Station Mode, and Client Control LED
PDF
IOT NodeMCU - NodeMCU Connection to Internet
PDF
Lesson 10- NodeMCU with LCD I2C
PDF
Lesson 9- NodeMCU with Arduino UNO (UART)
PDF
Lesson 8- NodeMCU with Servo Motor
PDF
Lesson 7- NodeMCU with DC Motor
PDF
Lesson 6 - NodeMCU with PWM Pin
PDF
lesson4 - NodeMCU control led
PDF
lesson2 - Nodemcu course - NodeMCU dev Board
PDF
lesson1 - Getting Started with ESP8266
PDF
Embedded system course projects - Arduino Course
PDF
Embedded system introduction - Arduino Course
PDF
Pyton with rasperry pi
PDF
Summary of MATLAB Functions-Part1
PDF
MATLAB Basics-Part1
PDF
Python basics_ part1
IOT NodeMCU - NodeMCU Webserver
IOT NodeMCU - Ubidots Platform to Turn on LEDs
IOT NodeMCU - Thinger Platform to Turn on LEDs
IOT NodeMCU - IFTTT Templet to send SMS
ESP8266 NodeMCU Server, Client, Station Mode, and Client Control LED
IOT NodeMCU - NodeMCU Connection to Internet
Lesson 10- NodeMCU with LCD I2C
Lesson 9- NodeMCU with Arduino UNO (UART)
Lesson 8- NodeMCU with Servo Motor
Lesson 7- NodeMCU with DC Motor
Lesson 6 - NodeMCU with PWM Pin
lesson4 - NodeMCU control led
lesson2 - Nodemcu course - NodeMCU dev Board
lesson1 - Getting Started with ESP8266
Embedded system course projects - Arduino Course
Embedded system introduction - Arduino Course
Pyton with rasperry pi
Summary of MATLAB Functions-Part1
MATLAB Basics-Part1
Python basics_ part1

Recently uploaded (20)

PDF
오픈소스 LLM, vLLM으로 Production까지 (Instruct.KR Summer Meetup, 2025)
PPTX
ANIMAL INTERVENTION WARNING SYSTEM (4).pptx
PPTX
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PDF
Model Code of Practice - Construction Work - 21102022 .pdf
PDF
ETO & MEO Certificate of Competency Questions and Answers
PDF
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
PDF
Geotechnical Engineering, Soil mechanics- Soil Testing.pdf
PPT
Project quality management in manufacturing
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PPTX
24AI201_AI_Unit_4 (1).pptx Artificial intelligence
PDF
algorithms-16-00088-v2hghjjnjnhhhnnjhj.pdf
PDF
Structs to JSON How Go Powers REST APIs.pdf
PPTX
MET 305 MODULE 1 KTU 2019 SCHEME 25.pptx
PPTX
The-Looming-Shadow-How-AI-Poses-Dangers-to-Humanity.pptx
PPTX
web development for engineering and engineering
PPTX
anatomy of limbus and anterior chamber .pptx
PPTX
bas. eng. economics group 4 presentation 1.pptx
PPTX
Unit 5 BSP.pptxytrrftyyydfyujfttyczcgvcd
PPTX
Road Safety tips for School Kids by a k maurya.pptx
오픈소스 LLM, vLLM으로 Production까지 (Instruct.KR Summer Meetup, 2025)
ANIMAL INTERVENTION WARNING SYSTEM (4).pptx
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
Model Code of Practice - Construction Work - 21102022 .pdf
ETO & MEO Certificate of Competency Questions and Answers
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
Geotechnical Engineering, Soil mechanics- Soil Testing.pdf
Project quality management in manufacturing
Operating System & Kernel Study Guide-1 - converted.pdf
24AI201_AI_Unit_4 (1).pptx Artificial intelligence
algorithms-16-00088-v2hghjjnjnhhhnnjhj.pdf
Structs to JSON How Go Powers REST APIs.pdf
MET 305 MODULE 1 KTU 2019 SCHEME 25.pptx
The-Looming-Shadow-How-AI-Poses-Dangers-to-Humanity.pptx
web development for engineering and engineering
anatomy of limbus and anterior chamber .pptx
bas. eng. economics group 4 presentation 1.pptx
Unit 5 BSP.pptxytrrftyyydfyujfttyczcgvcd
Road Safety tips for School Kids by a k maurya.pptx

Getting date and time from ntp server with esp8266 node mcu

  • 1. Internet ofThings Getting Date & Time From NTP Server With ESP8266 NodeMCU Eng. Elaf A.Saeed
  • 2. The Contents • NTP Server With ESP8266 NodeMCU. • Getting Day & Time From NTP Server With ESP8266 NodeMCU. • Getting Current Day and Time from NTP Server. • Getting Current Date and Time from NTP Server.
  • 3. Getting Day & Time & date From NTP Server With ESP8266 NodeMCU
  • 4. NTP Server With ESP8266 NodeMCU
  • 5. NTP Server With ESP8266 NodeMCU (cont.) • NTP stands for Network Time Protocol and it is a networking protocol for clock synchronization between computer systems. In other words, it is used to synchronize computer clock times in a network. • The protocol can be used to synchronize all networked devices to Coordinated Universal Time (UTC) within a few milliseconds ( 50 milliseconds over the public Internet and under 5 milliseconds in a LAN environment). • Coordinated Universal Time (UTC) is a world-wide time standard, closely related to GMT (Greenwich Mean Time). UTC does not vary, it is the same world wide.
  • 6. NTP Server With ESP8266 NodeMCU (cont.) ❑NTPArchitecture • NTP uses a hierarchical architecture. Each level in the hierarchy is known as a stratum. • At the very top are high-precision timekeeping devices, such as atomic clocks, GPS or radio clocks, known as stratum 0 hardware clocks. • Stratum 1 servers have a direct connection to a stratum 0 hardware clock and therefore have the most accurate time. • Each stratum in the hierarchy synchronizes to the stratum above and act as servers for lower stratum computers.
  • 7. NTP Server With ESP8266 NodeMCU (cont.) ❑How NTP Works? • NTP can operate in a number of ways. The most common configuration is to operate in client-server mode. The basic working principle is as follows: 1. The client device such as ESP8266 connects to the server using the User Datagram Protocol (UDP) on port 123. 2. A client then transmits a request packet to a NTP server. 3. In response to this request the NTP server sends a time stamp packet. 4. A time stamp packet contains multiple information like UNIX timestamp, accuracy, delay or time zone. 5. A client can then parse out current date & time values.
  • 8. NTP Server With ESP8266 NodeMCU (cont.) ❑Installing the NTPClient Library • We’ll use the NTPClient library to get time. In your Arduino IDE, go to Sketch > Library > Manage Libraries. The Library Manager should open. • Search for NTPClient and install the library by Fabrice Weinber as shown in the following image.
  • 9. Getting Day & Time From NTP Server With ESP8266 NodeMCU
  • 10. Getting Day & Time From NTP Server With ESP8266 NodeMCU ❑NTPClient Library Time Functions • getDay() – returns an int number that corresponds to the the week day (0 to 6) starting on Sunday; • getHours() – returns an int number with the current hour (0 to 23) in 24 hour format; • getMinutes() – returns an int number with the current minutes (0 to 59); • getSeconds() – returns an int number with the current second; • getEpochTime() – returns an unsigned long with the epoch time (number of seconds that have elapsed since January 1, 1970 (midnight GMT); • getFormattedTime() – returns a String with the time formatted like HH:MM:SS;
  • 11. Getting Day & Time From NTP Server With ESP8266 NodeMCU (cont.)
  • 12. Getting Current Day and Time from NTP Server (cont.)
  • 13. Getting Current Day and Time from NTP Server (cont.)
  • 14. Getting Current Date and Time from NTP Server ❑Function that is used in Code 1. year()➔ Set or read the RTC year value. Syntax year(unsigned long year) 2. month() ➔ Set or read the RTC month value. Syntax month(unsigned long month) 3. day() ➔ Set or read the RTC day value. Syntax day(unsigned long day)
  • 15. Getting Current Date and Time from NTP Server (cont.) ❑Function that is used in Code 4. minute() ➔ Set or read the RTC minute value. Syntax: minute(unsigned long minute) 5. second() ➔ Set or read the RTC second value. Syntax: second(unsigned long second) .
  • 16. Getting Current Date and Time from NTP Server (cont.)
  • 17. Getting Current Date and Time from NTP Server (cont.)
  • 18. Getting Current Date and Time from NTP Server (cont.)
  • 19. Getting Current Date and Time from NTP Server (cont.)