Skip to content

DS3231 Real Time Clock~

This feature is not included in precompiled binaries

When compiling your build add the following to user_config_override.h:

#ifndef USE_RTC_CHIPS 
#define USE_RTC_CHIPS               // Enable RTC chip support and NTP server
#endif
#ifndef USE_DS3231
#define USE_DS3231                  // [I2cDriver26] Enable DS3231 RTC (I2C address 0x68) (+1k2 code)
#endif
If you use a DS3231 with a different I2C address, uncomment and change your address with:
#define USE_RTC_ADDR    0x68                  

Tasmota requires that its system time is set in order to use timers. Usually, when the device boots, it gets the time and date from an an NTP (Network Time Protocol) server located somewhere on the Internet. When there is no Internet connection, Tasmota is not able to request the current date and time. The DS3231 is an external Real Time Clock (RTC) component used for keeping the time and date set in the device when it cannot establish an Internet connection.

Optionally, the Time command is available to manually set date and time for the real time clock. The DS3231 will evaluate this time and sync to it if date is later than Jan 1, 2016. Note that the Time command will disable NTP sync, and the real time clock will drift based on the accuracy of the DS3231 module.

The RTC driver optionally includes a simple NTP server enabled by #define RTC_NTP_SERVER. It will respond to NTP requests on the standard port 123 as a stratum 1 server. This is useful as a backup time source for network devices if internet access is unavailable. NTP server can be activated with the command RtcNtpServer 1 and deactivated with RtcNtpServer 0

Configuration~

Wiring~

DS3231 ESP
GND GND
VCC 3.3V
SDA GPIOx
SCL GPIOy

Tasmota Settings~

In the Configuration -> Configure Module page assign:

  1. GPIOx to I2C SDA
  2. GPIOy to I2C SCL

Wiring on D1 mini~

Tasmota Settings~

Any time your device has an NTP connection, the DS3231 internal clock will be set automatically. The first time RTC is used, you must have an Internet connection. From that point forward, the time is stored in the RTC and the device time will be restored from the RTC when there is no Internet connection.

You can use your mobile phone hotspot for your device in a location where it can't get a Wi-Fi connection

Check that the time is set correctly by inspecting the log in the Console. You should see messages that Tasmota read or wrote the time from and to the DS3231. Make sure that the time is set correctly even when you do not have Internet connection.