Raspberry I2C

Raspberry PI I2C clock with the nice and small "DS3231 For PI" RTC module.

# install teh I2C tools
apt-get install i2c-tools

Eg. howto (I2C for PI)

# 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
echo ds1307 0x68 | sudo tee /sys/class/i2c-adapter/i2c-1/new_device

Set the date like this:

hwclock --set --date '2013/11/12 10:31'

And query it:


(I get Tue Nov 12 10:31:07 2013 -0.982126 seconds)

That's it! You can also add the i2c initialisation command to rc.local which means it will be run at every boot up;

# 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
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

Other clocks: http://www.framboise314.fr/avant-lheure-cest-pas-lheure-apres-lheure-offrez-une-horloge-temps-reel-rtc-a-votre-raspberry-pi/#more-1697

electronics/raspi/i2c.txt · Last modified: 2014/10/14 17:07 by jim
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki