How to set up i²c in Raspbian on the Raspberry Pi

First we need to update our package lists.

sudo apt-get update

Then we install smbus

sudo apt-get install python-smbus

install smbus for i2c

y to confirm

smbus installed

This installed i2c-tools as well, which we’ll use a little later to locate i2c devices on the system.

How to Enable i2c in Raspbian

Then we need to make a tweak to a couple of configuration file to enable i2c in raspbian.

To enable i2c in raspbian…

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

…and comment out line 3 (the one with i2c in) by inserting a # at the start of the line…
ctrl+o save
<ENTER> confirm filename
ctrl+x exit

commented out the i2c line (3)

sudo nano /etc/modules
you need to add…
i2c-dev on the last line

Add i2c-dev on last line

ctrl+o save
<ENTER> confirm filename
ctrl+x exit

Now we need to reboot to activate the new settings. You could do any necessary wiring while the Pi is powered down. (Do disconnect the power after shutting down) 🙂

sudo reboot to reboot, or sudo halt to shut down.

Short URL:

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!