The Pragmatic Addict

Raspberry Pi Real Time Clock (RTC) DS3231

One of the features lacking on a Raspberry PI is a Real Time Clock (RTC). This is basically a battery backed up clock that the PI can sync with to maintain clock accuracy.

I2C configuration

Install i2c-tools

apt-get install i2c-tools

Enable I2C in raspi-config

Enable Interface Options/I2C

Add the following to /boot/firmware/config.txt

dtoverlay=i2c-rtc,ds3231

Reboot

Confirm configuration

Check for I2C connectivity to the RTC. The address 0x68 should be listed after running this command:

i2cdetect -y 1

Remove fake-hwclock

apt-get remove --purge fake-hwclock

Modify & Comment the following /lib/udev/hwclock-set

#if [ -e /run/systemd/system ] ; then
#    exit 0
#fi

Test read the RTC

hwclock --verbose --show

Initalize the RTC with the systemclock

hwclock --systohc

Verify the RTC was written

hwclock --show

Created: 2024-02-20 Modified: 2024-04-01