Real Time Clock RTC
Adding a RTC to the Hive Interface board version 0.3. (Skip the first section, Hardware, if using version 1.0 of the interface board as these modifications have been added to the board.)
This module almost plugs in to H2 (the I2C bus) on version 0.3 of the Hive Interface board. A minor modification is required on version 0.3 interface boards. This modification was incorporated into later versions. As +5 VDC is not used and the ground must be shifted down a pin:
- The ground on C3 must be moved.
- To be safe, the 4th pin of a 1x5 male header should be removed.
- Solder the 1x5 header in H2 BUT SHIFT IT DOWN ONE PIN.
|Old H2 I2C Bus||New H2 for RTC|
|2||+3.3||Pin 1 of H2|
|3||I2C||Pin 2 of H2|
|4||I2C||Pin 3 of H2|
|Ground for C||Ground||Pin 5 of H2|
These instructions have recently been updated and work well:
The hwclock is read on boot. When the ntp servers are available, the system time is synced to them and the system time is written to the hwclock every 11 minutes. From the hwclock man page:
Automatic Hardware Clock Synchronization By the Kernel You should be aware of another way that the Hardware Clock is kept synchronized in some systems. The Linux kernel has a mode wherein it copies the System Time to the Hardware Clock every 11 minutes. This is a good mode to use when you are using something sophisticated like ntp to keep your System Time synchronized. (ntp is a way to keep your System Time synchronized either to a time server somewhere on the network or to a radio clock hooked up to your system. See RFC 1305). This mode (we'll call it "11 minute mode") is off until something turns it on. The ntp daemon xntpd is one thing that turns it on. You can turn it off by running anything, including hwclock --hctosys, that sets the System Time the old fashioned way.
Turn on I2C
5 Interfacing Options
and enable it.
sudo apt-get update sudo apt-get install python-smbus i2c-tools
This wasn't necessary as they were both already installed and the latest version in the 0.7.4 image.
Edit /boot/config.txt. Add:
#enable RTC DS3231 module dtoverlay=i2c-rtc,ds3231
Edit /lib/udev/hwclock-set and comment out these three lines:
#if [ -e /run/systemd/system ] ; then # exit 0 #fi