I2C is a very commonly used standard designed to allow one chip to talk to another. So, since the Raspberry Pi can talk I2C we can connect it to a variety of I2C capable chips and modules.
The I2C bus allows multiple devices to be connected to your Raspberry Pi, each with a unique address, that can often be set by changing jumper settings on the module. It is very useful to be able to see which devices are connected to your Pi as a way of making sure everything is working.
sudo apt-get install -y python3-smbus sudo apt-get install -y i2c-tools
Installing Kernel Support (with Raspi-Config)
Run sudo raspi-config and follow the prompts to install i2c support for the ARM core and linux kernel
Go to Interfacing Options
On older versions, look under Advanced
then I2C
Enable!
sudo reboot
sudo i2cdetect -y 1
This shows that two I2C addresses are in use – 0x40 and 0x70.
These values will be different for you depending on what is currently attached to the I2C pins of your Raspberry Pi
Note that if you are using one of the very first Raspberry Pis (a 256MB Raspberry Pi Model B) then you will need to change the command to:
sudo i2cdetect -y 0
The Raspberry Pi
designers swapped over I2C ports between board releases. Just remember: 512M Pi's use i2c port 1, 256M ones use i2c port 0!
When you are finished in raspi-config reboot for the i2c modules to automatically load into the kernel.
Text editor powered by tinymce.