Knowledge Base

The AB Electronics UK Knowledge Base provides support solutions, tutorials and troubleshooting guides.

I2C, SMBus and Raspbian Wheezy Linux

Find out how to set up I2C communication on the Rasberry Pi using i2c tools.
Created: 29/06/2017 | Last Updated: 29/06/2017

This page details how to setup I2C support on the Raspbian "Wheezy" image from http://www.raspberrypi.org/downloads

To use your Raspberry Pi with Raspbian Jessie or later please use our Raspbian Jessie I2C support tutorial.

Step 1: Download the Raspbian "Wheezy" linux image and burn to your SD Card following the instructions on http://elinux.org/RPi_Easy_SD_Card_Setup

If you are using Raspian Linux 3.18 or later you need to go into the raspberry pi config utility and enable I2C.

sudo raspi-config

Select 5 Interfacing Options and then  P5 I2C. A prompt will appear asking Would you like the ARM I2C interface to be enabled?, select Yes, exit the utility and reboot your raspberry pi.

sudo reboot

Step 2: Next you need to update your Raspberry Pi to ensure all the latest packages are installed:

sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade

Step 3 a:  Once you have logged into your Raspberry Pi from the command line, run the following command to install SMBus and Python Dev:

sudo apt-get install python-smbus python3-smbus python-dev python3-dev

Step 4:  From the command line, run the following command to install i2c-tools:

sudo apt-get install i2c-tools

For previous releases before Raspian Linux 3.18 you need to complete the following steps:

Step 5: Enable I2C and SPI protocols. I2C and SPI protocols are turned off in the wheezy distro by default, so you will need to enable them by editing the file /etc/modprobe.d/raspi-blacklist.conf :

sudo nano /etc/modprobe.d/raspi-blacklist.conf

In the file you will see two lines, you need to disable the blacklisting of these by adding a # character before each line:

#blacklist spi-bcm2708
#blacklist i2c-bcm2708

Save your changes and exit the nano editor.

Step 6:

For recent versions of the Raspberry Pi (3.18 kernel or later) you will need to update the /boot/config.txt file.  Open the file with nano using the command:

sudo nano /boot/config.txt

Add the following text to the bottom of the file:

dtparam=i2c1=on
dtparam=i2c_arm=on

Save your changes and exit the nano editor.

All versions:

Step 7: Set the Raspberry Pi to start I2C automatically at boot by editing /etc/modules :

sudo nano /etc/modules

Use your cursor keys to move to the last line and add a new line and then add:

i2c-dev

Save your changes and exit the nano editor.

Step 8: To avoid having to run the I2C tools at root add the ‘pi’ user to the I2C group:

sudo adduser pi i2c

Step 9: Next reboot the Raspberry Pi:

sudo reboot

When your Raspberry Pi has rebooted you will now have I2C and SMBus Python 2 or 3 support.

Was this article helpful? Yes / No