Before you can get started with I2C on the Pi, you'll need to run through a couple quick steps from the console.
If you are running Rasbian and are familiar with Terminal commands, then the description below will be sufficient.
If not, then to learn more about how to setup I2C with Raspbian, then take a minor diversion to this Adafruit Tutorial: http://learn.adafruit.com/adafruits-raspberry-pi-lesson-4-gpio-setup/configuring-i2c
When you are ready to continue, enter the following commands to add SMBus support (which includes I2C) to Python:
sudo apt-get install python-smbus sudo apt-get install i2c-tools
i2c-tools isn't strictly required, but it's a useful package since you can use it to scan for any I2C or SMBus devices connected to your board. If you know something is connected, but you don't know it's 7-bit I2C address, this library has a great little tool to help you find it. python-smbus is required, it adds the I2C support for python!
If you have an Original Raspberry Pi (Sold before October 2012) - the I2C is port 0:
sudo i2cdetect -y 0
sudo i2cdetect -y 1
Page last edited March 08, 2024
Text editor powered by tinymce.