Hardware:
Connect GND, 3.3V VCC, SDA, SCL from the RTC to corresonding RPI pin header.
RPI configuration:
Add configuration to pick up the RTC, this is using the ds3231 RTC, use the correct value if you have a different RTC.
edit /boot/config.txt
Code: Select all
dtparam=i2c_arm=on
dtoverlay=i2c-rtc,ds3231
Code: Select all
hwclock --systohc
Code: Select all
apt-get purge fake-hwclock
edit /etc/udev/rules.d/85-hwclock.rules
Code: Select all
# On the Raspberry Pi the RTC isn't available when systemd tries,
# set the time from RTC now when it is available.
KERNEL=="rtc0", RUN+="/sbin/hwclock --rtc=$root/$name --hctosys"
Many instructions say to edit /lib/udev/hwclock-set and commit out an exit 0 line. The problem is you have to do that every time util-linux is upgraded. I'm adding a new udev rule in /etc where you only have to do it once.
Removing fake-hwclock is optional, it could be nice as a backup. I'm removing it to make it more obvious when the RTC isn't working. The system time starts at 2016-11-03, so if you see this time it is a good indication the RTC isn't working.
All commands must be run as root.