How to enable I2C on Raspberry Pi.

How to enable I2C on Raspberry Pi.

0 Share

How to enable I2C on Raspberry Pi.

In order to establish communication on the Pi-Cubes Main  board with Raspberry Pi to communicate with I/O Modules and integrated RTC (Real Time Clock) I2C has to be enabled on ...

In order to establish communication on the Pi-Cubes Main  board with Raspberry Pi to communicate with I/O Modules and integrated RTC (Real Time Clock) I2C has to be enabled on the Raspberry Pi. Pi Cubes Main board is using I2C-0 to communicate with RTC and I2C-1 to communicate with Pi-Cube I/O modules.
Follow next steps to enable I2C:

1.  Run “sudo raspi-config” to enable I2C

sudo raspi-config

2.  Reboot Raspberry Pi

3.  Run “sudo nano /etc/modules”

sudo nano /etc/modules

If next lines don’t exist add them :

i2c-bcm2708
i2c-dev

 

1

Use Ctrl-X to exit and save module file.

4.  Run “sudo nano /etc/modprobe.d/raspi-blacklist.conf” and make sure that I2C is not blacklisted there, if I2C is blacklisted then  add # in the front to comment out.

 

2

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

5.  In order to enable both I2C ports that we need, we have to edit /boot/config.txt
That is done with :

sudo nano /boot/config.txt

Add next lines if they are not there :

dtparam=i2c0=on
dtparam=i2c1=on
dtparam=i2c_arm=on

 

3

Exit and save it , reboot Raspberry Pi.

6.  Install I2C tools for testing:

sudo apt-get install i2c-tools

7.   Run a test on i2c-0 with “sudo i2cdetect –y 0”

sudo i2cdetect –y 0

You should see RTC (Real time clock) responding on the address 0x68.

 

4

8.  Run a test on i2c-1 with “sudo i2cdetect –y 1”

sudo i2cdetect –y 1

If you have PI Cubes I/O Module connected to the Pi Cubes Main board you should see respond on address 0x1C.

 

5

Now you have I2C ready on Raspberry Pi to communicate with IO Modules and RTC.

Leave a reply

Your email address will not be published.

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>