Thursday, August 7, 2014

i2c connection in Raspberry Pi

What is i2c ?
 
I²C (Inter-Integrated Circuit), pronounced I-squared-C, is a multi-master, multi-slave, single-ended, serial computer bus invented by Philips Semiconductor, known today as NXP Semiconductors, used for attaching low-speed peripherals to computer motherboards and embedded systems. Alternatively I²C is spelled I2C (pronounced I-two-C) or IIC (pronounced I-I-C).
 
I heard about i2c , but never experimented something with i2c connections. Now I have an opportunity to do that with Raspberry pi. Its kind of Master -Slave communication or address to address communication.Advantage of this is , with 2 pins ( SDA,SDL) you can control many pins of  a device or IC which having i2c provision.
 
Raspberry Pi have i2c communication provision:
 
 
 
Raspberry  i2c set up procedure:
 
 
 
To use the I²C module with the Raspberry Pi, follow the below steps

1.Enable the I²C driver on the Pi by typing sudo vi /etc/modprobe.d/raspi-blacklist.conf
comment the line blacklist i2c-bcm2708 with an #
and save the file
2.Edit the modules file with the command sudo vi /etc/modules and add "i2c-dev" to a new line, then save the file
3.Install the i2c-tools package: sudo apt-get install i2c-tools.
4.Install the python 'smbus' module: sudo apt-get install python-smbus.
5.reboot raspberry pi
6.After the reboot, test to see if there is a device connected with the command i2cdetect -y 0
 
Activate the I²C device with sudo modprobe i2c-dev. This must be done whenever the Pi is restarted.
 

 
 
 
Reference :
 

No comments: