The Raspberry Pi does not have an RTC clock, so the system time is inaccurate after each power cycle. To solve this problem, we designed this module to provide real-time clock for the Raspberry Pi, so that even if your Raspberry Pi is accidentally powered off, the time can still be maintained.
First, insert the module to your Raspberry Pi.
Then, start the I2C interface.
You can add the device tree to PI to support the RTC module, run
sudo nano /boot/config.txt
Add dtoverlay=i2c-rtc,ds3231 to the end of the file.
Save and reboot, run sudo i2cdetect -y 1 to check if your PI recognize the modle, as shown below:
Run below command to close the false-hw clock
sudo apt-get -y remove fake-hwclock
sudo update-rc.d -f fake-hwclock remove
sudo systemctl disable fake-hwclock
Now, we can start the hardware clock.
Sudo nano /lib/udev/hwclock-set, and comment there 3 lines of code
#if [ -e /run/system/system ];then
# exit 0
# /sbin/hwclock –rtc=$dev –systz –badyear
# /sbin/hwclock –rtc=$dev –systz
The time is wrong when the module inserted to Pi for the first time, we need to set a time first. Please use below command to set the time.
sudo hwclock -D -r
sudo hwclock -w