Thanks to the NTP server, ESPEasy is able to call up the time via the WiFi connection. This option is very easy to set up and is described, for example, here: ESPEasy - Activate NTP time retrieval from the Internet
But what if no NTP server is available for the time retrieval?
In this case you can use an RTC (= Real Time Clock). This is an IC that "keeps up" the set time with battery backup. The time is saved once in this IC and, thanks to the backup battery, continues to be counted even after a power failure (or switching on and off).
After restarting the actual controller (in this case the ESP32 or ESP8266) it can retrieve the time from the RTC-IC and thus knows the current time again.
A "famous" IC that offers this functionality is the DS3231 or DS3232. Thanks to the plug-in described below, its functionality can be integrated relatively easily into ESPEasy. Everything you need to know is described in the following article.
I know the following hints are always a bit annoying and seem unnecessary. But unfortunately, many people who knew it "better" from carelessness lost their eyes, fingers or other things or hurt themselves. In comparison, a loss of data is almost not worth mentioning, but even these can be really annoying. Therefore, please take five minutes to read the safety instructions. Even the coolest project is worth no injury or other annoyance. https://www.nerdiy.de/en/sicherheitshinweise/
Affiliate links / advertising links
The links to online stores listed here are so-called affiliate links. If you click on such an affiliate link and store via this link, Nerdiy.de receives a commission from the online store or provider concerned. The price doesn't change for you. If you do your purchases via these links, you will support Nerdiy.de in being able to offer further useful projects in the future. 🙂
You can find additional tips on ESPEasy in the following articles.
- ESPEasy - Execute commands and actions via HTTP, MQTT, UDP and directly
- ESPEasy - Compile firmware, flash it and configure WiFi access data
- ESPEasy/Wemos D1 Mini - Adapt ADC to a different maximum voltage
In the following list you will find all the parts you need to implement this article.
|1x||Wemos D1 Mini Buy at Amazon|
|1x||DS3231 Real Time Clock Buy at Amazon|
|1x||USB power supply 5V/3.4A Buy at Amazon|
|1x||Wires Buy at Amazon|
|1x||Breadboard Buy at Amazon|
Connect the DS3232 or DS3231 to the ESP8266
The DS3232 or DS3231 is connected to the ESP8266 or Wemos D1 Mini via the I2C bus.
If the I2C bus is configured as standard, you can use the circuit diagram shown as a guide.
Configuration of the DS3232 or DS3231 in ESPEasy
So that the DS3232 or DS3231 can be configured in ESPEasy, the ESPEasy firmware should already be installed and accessible on the ESP8266 or ESP32. You can find information on this in the article ESPEasy - Compiling, flashing and configuring WiFi access data.
First open the configuration website of your ESP8266 programmed with ESPEasy by entering its IP address in your web browser. Information on how you can find out the IP address is also summarized in the article Show / find out the IP address of the devices in the network.
As soon as you have opened the configuration website, you have to switch to the "Devices" tab. To do this, click on the "Devices" button.
In the "Devices" tab you now have to click on the "Add" button in one of the empty lines.
You will then be automatically redirected to the view shown and ...
... you can choose here which device you want to create.
Select the entry here
- TIME - DS323X
If the entry you are looking for is not listed, the plug-in is not included in your ESPEasy installation. A precompiled binary which also contains this plugin can be found under the following link.
This will redirect you to an overview page.
Here you can adjust all settings regarding the DS3231 or DS3232.
If you have used the circuit diagram shown above, you can use the settings shown.
Depending on the configuration, you have to check the box next to "Force Slow I2C Speed". Usually this is not necessary.
With the check mark "Enable NTP sync at startup" you can activate the automatic synchronization with an NTP server. This means that the RTC - assuming correctly configured access to the NTP server - is automatically set to the current time.
How to configure an NTP server is described here: ESPEasy - Activate NTP time retrieval from the Internet
With the data acquisition interval you can set the time interval at which the time is read out in the RTC and synchronized with the system time of the ESP32 or ESP8266.
If you have configured everything correctly you have to click on "Submit" to apply the settings.
As an alternative to setting the time via the configured NTP server, you can also use the following commands to adjust the set time.
- nrdy_rtc_incrhr - Increases the hour value of the saved time by one.
- nrdy_rtc_decrhr- Decreases the hour value of the saved time by one.
- nrdy_rtc_incrmnt - Increases the minute value of the saved time by one.
- nrdy_rtc_decrmnt - Decreases the minute value of the saved time by one.
Other sensors and actuators for connection to the ESP8266 / ESP32
You can find an overview of other articles for connecting sensors and actuators to ESPEasy in the following category.
Have fun with the project
I hope everything worked as described. If not or you have any other questions or suggestions, please let me know in the comments. Also, ideas for new projects are always welcome. 🙂
P.S. 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 appreciate that I share this information with you, I would be happy about a small donation to the coffee box. 🙂