Raspberry Pi‎ > ‎GPIO Driver and Library‎ > ‎I2C‎ > ‎

I2C Device

IO Device

    Anything related to IO and GPIO Device Test and Sample

idle3 run as root

  • Modify /Desktop/idle3.desktop as EXEC=sudo idle 

I2C Installation for Raspberry Pi – Step by Step Guide


This is a step by step guide on installation I2C driver for the Raspberry Pi. It is for the Raspbian image.

Raspberry Pi Starter Kits

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.



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:



i2cdetect means

Means : BUS number for Read and Write Address 

import smbus
import time
bus = smbus.SMBus(0)
address = 0x70


def write(value):
        bus.write_byte_data(address, 0, value)
        return -1

def lightlevel():
        light = bus.read_byte_data(address, 1)
        return light

def range():
        range1 = bus.read_byte_data(address, 2)
        range2 = bus.read_byte_data(address, 3)
        range3 = (range1 << 8) + range2

        return range3

while True:
        lightlvl = lightlevel()
        rng = range()
        print lightlvl
        print rng


WebIOPi is developed and tested on Raspbian. You only need Python, either 2.7 or 3.2. Download, then extract and install WebIOPi. The setup script will automatically download and install required dependencies using apt-get. You may have to manually install GCC and Python development headers if you are not using Raspbian.

Update note: Stop your existing WebIOPi service, then process with the setup. Your configuration will be kept but others files will be override.

See downloads page to get latest package, and adapt x.y.z with the version you download.

$ tar xvzf WebIOPi-x.y.z.tar.gz
$ cd
$ sudo