To improve my stratum 1 clock, I added something I wish the RPi had from the factory, a real time clock (RTC).
I found a cheap DS3231 rtc module, which is the successor to the less accurate DS1307. The module I found just plugged into pins 1 (3v3),3 (SDA), 5(SCL), 7(GPCLK0), and 9 (GND), which meant it didn’t interfere with the pins I used for the GPS module. Even better, it was only around $1 shipped.
Here are the steps to improving the long term accuracy and precision of the ultra cheap stratum 1 clock.
After plugging it in and making sure to match + with 3.3v (1) and – with GND (9)
#remount the boot partition read-write mount -o remount,rw /media/mmcblk0p1 #update the boot config to start i2c cat >> /media/mmcblk0p1/usercfg.txt <<EOF /sys/class/i2c-adapter/i2c-1/new_device EOF reboot
After the pi reboots, you should set the RTC to a good time with chrony.
#initialize the new RTC module echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-1/new_device #stop services service chronyd stop service gpsd stop #update the RTC to a good time chronyd -q hwclock -w #start the services back up service chronyd start service gpsd start
To make it persist across reboots.
cat > /etc/local.d/00_rtc.start <<EOF #!/bin/sh echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-1/new_device sleep 1 hwclock -s EOF #make it executable chmod a+x /etc/local.d/00_rtc.start #add the local script to initialize the RTC rc-update add local boot #save all this hard work lbu ci -dv