Get Epoch/Unix time via NTP
NTP stands for "Network Time Protocol", and it is a network protocol for clock synchronization between computer systems. In other words, it is used to synchronize the computer clock time in the network.
This article will introduce how to use the NodeMCU ESP32s development board with Arduino IDE to get Epoch/Unix time. Obtaining the epoch time is useful for timestamp readings, assigning unique names to files, and other applications. We will request the current epoch time from the NTP server, so the ESP32s development board needs to establish an Internet connection.
For development environment setup and WiFi connection, please refer to the previous article:
- [ NodeMCU-ESP32 development example-Arduino development environment setup ]
- NodeMCU-ESP32 Development Example-Connect to WiFi
1. Prepare the hardware
- One NodeMCU-ESP32s development board
- One data line
- A laptop
It is assumed that the WiFi network has been set up through the router and the Internet can be accessed. The NodeMCU-ESP32s development board is connected to the computer through a data cable. </