5

DS3231 Real Time Clock

 2 years ago
source link: https://tasmota.github.io/docs/DS3231/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

DS3231 Real Time Clock~

This feature is not included in precompiled binaries

To use it you must compile your build. Add the following to user_config_override.h:

#ifndef USE_DS3231
#define USE_DS3231          // DS3231 external RTC (+1k2 code)
//    #define USE_RTC_ADDR  0x68                   // Default I2C address 0x68
#endif

If you use a DS3231 with a different I2C address, uncomment and change to your address:

#define USE_RTC_ADDR  0x68                  

Tasmota requires that its time be 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 DS3231 driver includes a simple NTP server based on the code used for the GPS driver. 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 Sensor33 1 and deactivated with Sensor33 0

Configuration~

Wiring~

DS3231 ESP8266
GND GND
VCC 3.3V
SDA GPIOx
SCL GPIOy

Tasmota Settings~

In the Configuration -> Configure Module page assign:

  1. GPIOx to I2C SDA (6)
  2. GPIOy to I2C SCL (5)

Wiring on Wemos D1 mini

wemos_tsl2561_config_marked.jpg?raw=true

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.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK