NTP (Network Time Protocol) is a clock protocol that synchronize between servers and computers system, attach to the data networks. NTP was designed by David Millis at the University of Delaware. NTP is envisioned to synchronize all participating computers of coordinated universal time (UTC) a modified version of Marzullos Algorithm to select an accurate time servers. NTP can usually maintain the time within tens of milliseconds over the internet and can accomplish better that one millisecond accuracy in the local area networks. NTP is usually describe in terms of a client server model but it can easily be used in peer to peer connection where both peers consider the other to be a possible time source. NTP uses User Datagram Protocol (UDP) at port 123, it can also use broadcasting or multicasting where clients possibly attend to time and updates after an initial round trip calibrating exchange. NTP also provide an alert of any about to happen leap second adjustment but there is no information about local time zone or daylight saving time is transmitted.

The NTP uses hierarchical semi layered system of time on each level named STRATUM and is assigned a number starting with 0 at the top the server synchronized to the stratum server and running at stratum n+1 the number represents the distance from reference clock used to prevent cyclical dependencies in the hierarchy. STRATUM is not always a sign of quality or reliability. It is most common find STRATUM 3 TIME source that are higher quality that STRATUM 2 source.

STRATUM 0 – is a precise timekeeping devices such as Atomic, GPS, and Radio Clocks. They generate a very accurate pulse per second signal that its triggers an interrupt and timestamp on a connected computer.

STRATUM 1 – Stratum 1 are computers are system clock are synchronized within microseconds of their attached stratum 0 devices. The stratum 1 servers may peer with other stratus 1 servers for rational checking backup this is also referred as primary time servers.

STRATUM 2 – Stratum 2 are computers that are synchronized over the network with STRATUS 1 servers. Stratum 2 computers will query stratus 1 servers. Stratus 2 devices may also peer with other STRATUM 2 devices to provide more stable, robust time for all device in group.

STRATUM 3 – Stratum 3 are computers that are synchronized to stratum 2 servers. This devices employ the same algorithm for peering data sampling as STRATUS 2 and can be act as servers for STRATUS 4 devices.

Network time protocol can be found in many devices and applications, especially in network appliances, operating systems, weather stations, market exchange etc. when the data receive runs at UDP at Port 123 it contains multiple information like UNIX timestamp, accuracy, delay or time-zone.

For more details about NTP > https://en.wikipedia.org/wiki/Network_Time_Protocol

Required Components 

  • ESP8266 12, 12E, ESP8266 NodeMCU, ESPDuino, WeMos.
  • 3.3v Regulator (AMS1117) / Voltage Step Down Module
  • Capacitor
  • Resistor
  • Solder Less Breadboard
  • Male Pin
  • Jumper Wires / DuPont Wires
  • Tactile Push Button

Pooling NTP Server on ESP8266

Driving ESP8266 Module to get data from the Network Time Protocol NTP server you need to set the code to communicate using UDP running at port 123.  To achieve this u need to use 2 libraries (ESP8266WIFI.H) & (WIFIUDP.H) library can be found at the Arduino ESP8266, here is the step how to integrate ESP8266 to your Arduino IDE. Both libraries are available after installing the library. However as you can see the code below you just need to place your AP SSID and Password make it sure you are connected to the internet to communicate with the NTP server just replay the NTPSERVER with any STRATUM service you want.

Wiring Diagram

Source Code

Wiring the ESP8266 12/12E as NTP Network Time Protocol via UDP as Stand Alone
Facebooktwittergoogle_plusredditpinterestmail
Tagged on:             

Leave a Reply

Your email address will not be published. Required fields are marked *