Thanks to NTP server ESPEasy is able to retrieve the time via WiFi connection. This possibility is very easy to set up and is described here, for example: ESPEasy - Enable NTP time retrieval from the Internet
But what if no NTP server is available for time retrieval?
In this case you can use a RTC (=real time clock). This is an IC, which "keeps up" the set time battery-buffered. So the time is stored once in this IC and thanks to the backup battery it will continue 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 respectively DS3232. Thanks to the plugin described below, its functionality can be integrated into ESPEasy relatively easily. Everything you need to know 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
- ESPEasy / Wemos D1 Mini - Adapt ADC to other maximum voltages
Required tool:
- none
Required material:
In the following list you will find all the parts you need to implement this article.
Number | Link |
---|---|
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 | Management Buy at Amazon |
1x | Pegboard Buy at Amazon |
Connecting the DS3232 or DS3231 to the ESP8266
The DS3232 or DS3231 is connected to the ESP8266 or Wemos D1 Mini via the I2C bus.
Configuration of the DS3232 or DS3231 in ESPEasy
To configure the DS3232 or DS3231 in ESPEasy, the ESPEasy firmware should already be installed on the ESP8266 or ESP32 and accessible. Information about this can be found in the article ESPEasy - Compile firmware, flash and configure WLAN access data.

First open the configuration website of your ESP8266 programmed with ESPEasy by entering its IP address into your web browser. Information on how to find out the IP address can also be found in the article Display/find out the IP address of the devices in the network summarized.
Once you have opened the configuration web page, you need to switch to the "Devices" tab. To do this, click on the "Devices" button.

...can select here which device you want to create.
Selects here the entry
- TIME-DS323X
off.
If the entry you are looking for is not visible, the plugin is not included in your ESPEasy installation. A precompiled binary which also contains this plugin can be found at the following link.

This will redirect you back to an overview page.
Here you can set 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 may have to check the "Force Slow I2C Speed" box. Normally this is not necessary.
With the checkmark "Enable NTP sync at startup" you can activate the automatic synchronization with an NTP server. This means that the RTC - assuming a correctly configured access to the NTP server - is automatically set to the current time.
With the Data-Acquisition Interval you can set in which time interval the time in the RTC is read out 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 stored time by one.
- nrdy_rtc_decrhr- Decreases the hour value of the stored time by one.
- nrdy_rtc_incrmnt - Increases the minute value of the stored time by one.
- nrdy_rtc_decrmnt - Decreases the minute value of the stored time by one.
Other sensors and actuators for connection to the ESP8266 / ESP32
An overview of other articles for connecting sensors and actuators to ESPEasy can be found in the following category.
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. 🙂