Enabling The I2C Port

You now use the raspbian config tool:


sudo raspi-config

Select 'Advanced Options' and then select the relevant option.

Enabling The I2C Port On Old Raspbian Distributions

The I2C ports need to be enabled in Raspbian before they can be used.

Edit the modules file

sudo nano /etc/modules

Add these lines:

i2c-bcm2708
i2c-dev

Exit and save the file

Now edit the modules blacklist file:

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

Add a '#' character to this line so it commented out:

#blacklist i2c-bcm2708

Exit and save the file.

​Finally install the I2C utilities:

sudo apt-get install python-smbus i2c-tools

Enter "sudo reboot" to restart the pi and now the I2C pins will be available to use.

 





USEFUL?
We benefit hugely from resources on the web so we decided we should try and give back some of our knowledge and resources to the community by opening up many of our company’s internal notes and libraries through mini sites like this. We hope you find the site helpful.

Please feel free to comment if you can add help to this page or point out issues and solutions you have found, but please note that we do not provide support on this site. If you need help with a problem please use one of the many online forums.

  • Michael Treat

    If I attach a Sense HAT to the pi, can I still use I2C? Thank you.