Difference between revisions of "Real Time Clock RTC"

From HiveTool
Jump to: navigation, search
(Software)
Line 70: Line 70:
 
  sudo apt-get install python-smbus i2c-tools
 
  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 kernel.  
+
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:
 
Edit /boot/config.txt.  Add:

Revision as of 16:02, 7 May 2017

Adding a RTC to the Hive Interface board.

DS3231

Hardware

This module almost plugs in to H2 (the I2C bus) on the Hive Interface board. A minor modification is required. As +5 VDC is not used and the ground must be shifted down a pin:

  1. The ground on C? must be moved.
  2. To be safe, the 4th pin of a 1x5 male header should be removed.
  3. Solder the 1x5 header in H2 BUT SHIFT IT DOWN ONE PIN.


H2 I2C Bus
Pin Signal New H2 for RTC
1 +5 No connect
2 +3.3 Pin 1 of H2
3 I2C Pin 2 of H2
4 I2C Pin 3 of H2
5 Ground No connect
Ground for C Ground Pin 5 of H2

Software

These instructions have recently been update and work well:

https://learn.adafruit.com/adding-a-real-time-clock-to-raspberry-pi/overview

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.
sudo raspi-config 

Select

5 Interfacing Options 

Select

P5 I2C

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