I2C Installation for Raspberry Pi

This is a step by step guide on installation I2C driver for the Raspberry Pi. It is for the Raspbian image. Make sure your Raspberry Pi is connected to the internet when installing the drivers.

The new Raspbian distro already have the I2C Driver installed but they are disabled by default. To enable it all you need to do is comment out a line by putting # in front. At the prompt type:
sudo nano /etc/modprobe.d/raspi-blacklist.conf
then add a # on the 3rd line.

Press CTRL X then y to save and exit.

Next edit the modules file by:
sudo nano /etc/modules
Add i2c-dev to a new line.

Press CTRL X then y to save and exit.

Now install the i2c-tools package by:
sudo apt-get install i2c-tools
If you get a 404 error do an update first:
sudo apt-get update
then run the install the i2c-tools again.

Note : The installation could take a few minutes to do, depend on how busy the server is.

Now add a new user to the i2c group:
sudo adduser pi i2c
Reboot the machine by:
sudo shutdown -r now
After the reboot test to see any device connected by:
sudo i2cdetect -y 0
If your board is the Rev 2 type this:
sudo i2cdetect -y 1
You should see something like this:

Next install the  python-smbus python module:
sudo apt-get install python-smbus
Now you are ready to use the i2c with python.

Example:

http://www.skpang.co.uk/blog/archives/454

Download the led chaser python file by:
wget http://www.skpang.co.uk/blog/wp-content/uploads/2012/06/ledchaser.py
Change the file permission to allow execute:
chmod 777 ledchaser.py
Run the example by:
./ledchaser.py

Short URL: http://tinyurl.com/ycet4jp4
   Send article as PDF   

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Do NOT follow this link or you will be banned from the site!