Thanks to WiFi and thus (often) also Internet connection, an ESP8266 or ESP32 programmed with ESPEasy also has the possibility to display the time.
For this to work, the retrieval of the time via an NTP server must first be activated in ESPEasy and a correct server must also be configured.
What you have to do to make ESPEasy automatically get the Current Time from an NTP time server is described in the following article.
Safety instructions
I know the following notes are always kind of annoying and seem unnecessary. Unfortunately, many people who knew "better" have lost eyes, fingers or other things due to carelessness or injured themselves. Data loss is almost negligible in comparison, but even these can be really annoying. Therefore, please take five minutes to read the safety instructions. Because even the coolest project is not worth injury or other trouble.
https://www.nerdiy.de/sicherheitshinweise/
Affiliate links/advertising links
The links to online shops listed here are so-called affiliate links. If you click on such an affiliate link and make a purchase via this link, Nerdiy.de will receive a commission from the relevant online shop or provider. The price does not change for you. If you make your purchases via these links, you support Nerdiy.de in being able to offer other useful projects in the future. 🙂
Requirements
Helpful articles:
Additional tips on ESPEasy can be found in the following articles.
- ESPEasy - Execute commands and actions via HTTP, MQTT, UDP and directly
- ESPEasy - Compile firmware, flash and configure WLAN access data
Required tool:
- none-
Required material:
Find out the address of a time server
There are many time servers on the Internet where you can get the time for free. You can find a quite extensive list for example also on https://www.ntp-server.de/ntp-server-deutschland/
It is advisable to choose NTP servers that are not far away. Therefore I would recommend to choose a time server from a German provider. In the following you can find for example a list of time servers which are offered by the PTB (Physikalisch-technische Bundesanstalt).
German NTP server of the PTB (Physikalisch-Technische Bundesanstalt)
PTB time server 1: ptbtime1.ptb.de
https://www.ntp-server.de/ntp-server-deutschland/
PTB time server 2: ptbtime2.ptb.de
PTB time server 3: ptbtime3.ptb.de
As an alternative, you can also use an even more “local” NTP server. Many home routers, for example, offer the same option. So instead of using an external time server, you simply use your router as a time server.
Tips on how to configure your FritzBox, for example, can also be found at the following link: https://avm.de/service/fritzbox/fritzbox-7590/wissensdatenbank/publication/show/336_Zeitsynchronisation-NTP-fur-FRITZ-Box-und-Netzwerkgerate-einrichten/
Configure time server in ESPEasy
Once you have found a time server that you want to use as a source for the time, all you have to do is enter it into your ESPEasy configuration.
To do this, go to the web interface of your ESPEasy device. To do this, enter the IP address of the device in the address line of your browser.
How to find out the IP address of devices in your network is also described in the article Display/find out the IP address of the devices in the network described.
Then go to the “Tools” area
Once you have arrived in the “Tools” area, you must now click on the “Advanced” button.
There you have the option to configure the NTP time server in the “NTP Settings” section.
To do this, tick the checkbox next to “Use NTP” and enter the desired time server under “NTP Hostname”.
If you prefer to use your router or, as in this example, your FritzBox as a time server, you can also enter the address of your router or FritzBox here. In the case of the FritzBox this is
fritz.box
As soon as you have entered the settings you have to save them.
To do this, scroll to the bottom of the configuration page and confirm the settings by clicking on “Submit”.
If you now switch back to the “Main” page, you should see the current date and time displayed in the overview in the “Local Time” section.
Set time zone
After you have set the correct time server, you may also need to configure the appropriate time zone. To do this, go back to the same page where you previously configured the NTP data. So Tools->Advanced.
There you can make the necessary settings in the “DST Settings” section. In addition to the exact dates when you want to switch from winter to summer time, you can also specify which time zone you are in under “Timezone Offset (UTC +)”.
Enter the deviation from your time zone (in minutes) and activate the checkbox in the “DST” section.
As soon as you have configured everything, you have to accept the data again by clicking on the “Submit” button.
What's the point?
A typical use case where you need the correct time is if you have built a pxlBlck for example. This can (if you wish) also show the current time on its LED display. You can find more information about this in the following articles.
- pxlBlck - An IOT/SmartHome Information System
- pxlBlck - Install and configure the pxlBlck plugin
- pxlBlck - configure clock faces and screensavers
Have fun with the project
I hope everything worked as described for you. If not or you have questions or suggestions please let me know in the comments. I will then add this to the article if necessary.
Ideas for new projects are always welcome. 🙂
PS Many of these projects - especially the hardware projects - cost a lot of time and money. Of course I do this because I enjoy it, but if you think it's cool that I share the information with you, I would be happy about a small donation to the coffee fund. 🙂
One comment