Enable I2C

Explore the Raspberry Pi
rwblinn
Site Admin
Posts: 224
Joined: 07 Oct 2017, 12:16

Enable I2C

Postby rwblinn » 15 Dec 2017, 08:55

Raspberry PI I2C Enabled
This is required when using an I2C device, like the BMP180 sensor.
I2C is a communication protocol that runs over a two wire bus with wires SDA (Serial Data) and SCL (Serial Clock).
The I2C bus can handle one or more masters (i.e. Raspberry Pi) and one or more slave devices (i.e.BMP180).
Each slave device must have its unique address (i.e. 77).

Pixel or Raspi-Config
Easiest was is to use Pixel > Preferences or raspi-config (from the command line).

Manual
In case Pixel or raspi-config are not installed, i.e. when using an image like openHABian, then use following steps.

Code: Select all

sudo apt-get update
sudo apt-get install i2c-tools libi2c-dev python-smbus


Do not use I2C the driver from the blacklist:

Code: Select all

sudo nano /etc/modprobe.d/raspi-blacklist.conf
#i2c-bcm2708

Skip this step, if no or empty raspi-blacklist.conf.

Edit the modules conf file.

Code: Select all

sudo nano /etc/modules
Add:
i2c-dev
i2c-bcm2708


Update /boot/config.txt

Code: Select all

sudo nano /boot/config.txt
Add:
dtparam=i2c_arm=on
dtparam=i2c1=on


Reboot.
Check the I2C address of the connected I2C device, i.e. BMP180.

Code: Select all

sudo i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- 77

The BMP180 has an I2C address 0x77.

Python
If using, then install the Python bindings python-smbus, to have SMBus access through the I2C interface.

Code: Select all

sudo apt-get install python-smbus

Return to “Raspberry Pi”



Who is online