Monday, August 11, 2014

Raspberry Pi RTC Module

Well I purchased this High Precision Real Time Clock for my Raspberry Pi.

They had a nice article on how to get it working here.

I pretty much followed it exactly and it worked fine, but I am going to relist the steps here in case I need them again later or the article moves etc.


# Remove the module blacklist entry so it can be loaded on boot
sudo sed -i 's/blacklist i2c-bcm2708/#blacklist i2c-bcm2708/' /etc/modprobe.d/raspi-blacklist.conf
# Load the module now
sudo modprobe i2c-bcm2708
# Notify Linux of the Dallas RTC device
# on my 256Mb Pi I used.
echo ds1307 0x68 | sudo tee /sys/class/i2c-adapter/i2c-0/new_device
# on my new Pi B+
#echo ds1307 0x68 | sudo tee /sys/class/i2c-adapter/i2c-1/new_device
# Test it out.
sudo hwclock

once that was done:
# Add the RTC device on boot
sudo sed -i 's#^exit 0$#echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-1/new_device#' /etc/rc.local
#dont forget to change i2c-0 or i2c-1
echo exit 0 | sudo tee -a /etc/rc.local
#This doesn't cover automatically setting the clock on boot and but you can do so by adding another line (above exit 0) to rc.local with;
hwclock -s

No comments:

Post a Comment