Apr 23, 2014

Configure i2c raspbian - wheezy

1. Install i2c-tools

sudo apt-get install i2c-tools

2.
On kernel version  < 3.18
Disable blacklisted module i2c-bcm2708, optional disable blacklisted spi-bcm2708 in /etc/modprobe.d/raspi-blacklist.conf

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

Other (DT - device tree) kernel versions
Add dtparam=i2c1=on (or dtparam=i2c0=on on old models) in /boot/config.txt





3. Add module running permanently by adding text  i2c-dev (at the end of file) to /etc/modules

sudo nano /etc/modules

4. Optional - add pi user to i2c group (no need for sudo while using i2c tools)

sudo adduser pi i2c

5. list available buses
i2cdetect -l

6. Try detect devices on bus (I2c1 - rpi rev3)
i2cdetect 1

7. Try get data from your chip
i2cget -y i2c-bus device-address register-address  [b | w]
ex.
i2cget -y 1 0x60 0x02 b

8. Try set data to your chip
i2cset -y i2c-bus device-address register-address data [b | w]
ex.
i2cset -y 1 0x60 0x02 0x55 b

9. When i2c device is used by driver, you must use -f  (force) parameter in i2c commands



More info:
http://www.lm-sensors.org/wiki/i2cToolsDocumentation
http://www.abelectronics.co.uk/i2c-raspbian-wheezy/info.aspx

No comments:

Post a Comment