DAC+ RTC: Configuring the RTC driver

The onboard real-time clock of the DAC+ RTC ensures that the Raspberry Pi always has the correct time on startup, even when no network is available.

To enable the drivers, you need to add only a few lines to /boot/config.txt and /etc/modules. Just login to the Raspberry Pi as root and copy/paste the following commands

echo "dtoverlay=i2c-rtc,ds1307" >> /boot/config.txt
echo "dtoverlay=hifiberry-dac" >> /boot/config.txt
echo "dtparam=i2c_arm=on" >> /boot/config.txt

echo "i2c-bcm2835" >> /etc/modules
echo "i2c-dev" >> /etc/modules
echo "rtc-ds1307" >> /etc/modules

Read RTC

If you want to test if everything is running fine and the RTC is configured correctly, you can run the following commands to read the current time directly from the RTC:

echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-1/new_device
hwclock -r

Set the RTC time

To set the RTC to the current system time, use the following commands:
echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-1/new_device
hwclock -w

Set system to to RTC time

This is the most important use case, as you will need to do this when the Raspberry Pi powers up:
echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-1/new_device
hwclock -s

udev configuration

ACTION=="add", SUBSYSTEM=="rtc", KERNEL=="rtc0", ATTR{hctosys}=="0", RUN+="/sbin/hwclock --rtc=%N --hctosys --utc"