I’m rather cheekily taking most of this from ThinkBowl.com as it’s a brilliant, simple walk-through that I’d hate to lose if the site disappeared! I’ve added some comments by way of explanation, just to add a little value.
- First install the i2c-tools:
apt-get install i2c-tools - Next SPI and I2C is “blacklisted” (i.e. turned off) from modprobe (the module loader) by default. Edit /etc/modprobe.d/raspi-blacklist.conf with vi or nano and comment out (place # as first character on line):
blacklist i2c-bcm2708 - To ensure modules are loaded at boot add the following lines to /etc/modules:
i2c-bcm2708
i2c-dev - Optional: If you are going to access the I2C from users other then root create a file called /etc/udev/rules.d/99-i2c.rules with the following line:
SUBSYSTEM==”i2c-dev”, MODE=”0666″
This will allow access from every user. To allow access only from a specific group:
SUBSYSTEM==”i2c-dev”, GROUP=”input”, MODE=”0666″ - Reboot the pi by issuing:
reboot - After the reboot, verify that the I2C devices are available:
ls /dev/i2c* - Optional: If you are using I2C with Python, you will need the smbus python library as it is not installed by default:
apt-get install python-smbus - Once you have the I2C device attached, you can determine the address by running:
i2cdetect -y <port>
Replace <port> with 0 for Revision 1 Raspberry Pis and with 1 for Revision 2 boards.
[…] recantha I’m rather cheekily taking most of this from ThinkBowl.com as it’s a brilliant, simple […]