Introduction: How to Use a Real-Time Clock Module (DS3231)
The DS3231 is a low-cost, extremely accurate I2C real-time clock (RTC) with an integrated temperature-compensated crystal oscillator (TCXO) and crystal. The device incorporates a battery input and maintains accurate timekeeping when main power to the device is interrupted.
Arduino Uno R3 - https://store.arduino.cc/usa/arduino-uno-rev3
DS3231 RTC Module - diymore DS3231 AT24C32 IIC RTC Module
Breadboard - MB-102 Breadboard
Step 1: Install Battery
The battery input is 3V and a typical CR2032 3V battery can power the module and maintain the information for more than a year.
Step 2: Connection
Wiring the RTC module is pretty straightforward!
VCC -> Arduino 5V
GND -> Arduino GND
SCL -> SCL or A5
SDA -> SDA or A4
Step 3: Library
Arduino library for the DS3231 real-time clock (RTC) can be installed directly in Library Manager.
Step 4: Setting Up the Clock
The clock is most likely set to 1 January 1970 initially. If you need real-time in your projects, synchronize this RTC with your computer.
Looked into the DS3231_set example from the DS3231 library and it seems like it expects a date sent in this format YYMMDDwHHMMSS, with an 'x' at the end.
Few lines of Python code using pyserial and ntplib should get time from the time server and send a string to Arduino.
Step 5: Test RTC
In library, examples find DS3231/echo_time.ino. Upload it to Arduino and you should see time printed in serial monitor.