How to enable I2C on Raspberry Pi.
In order to establish communication on the Pi-Cubes Main board with Raspberry Pi to communicate with I/O Modules and integrated RTC (Real Time Clock) I2C has to be enabled on the Raspberry Pi. Pi Cubes Main board is using I2C-0 to communicate with RTC and I2C-1 to communicate with Pi-Cube I/O modules.
Follow next steps to enable I2C:
1. Run “sudo raspi-config” to enable I2C
2. Reboot Raspberry Pi
3. Run “sudo nano /etc/modules”
sudo nano /etc/modules
If next lines don’t exist add them :
Use Ctrl-X to exit and save module file.
4. Run “sudo nano /etc/modprobe.d/raspi-blacklist.conf” and make sure that I2C is not blacklisted there, if I2C is blacklisted then add # in the front to comment out.
sudo nano /etc/modprobe.d/raspi-blacklist.conf
5. In order to enable both I2C ports that we need, we have to edit /boot/config.txt
That is done with :
sudo nano /boot/config.txt
Add next lines if they are not there :
Exit and save it , reboot Raspberry Pi.
6. Install I2C tools for testing:
sudo apt-get install i2c-tools
7. Run a test on i2c-0 with “sudo i2cdetect –y 0”
sudo i2cdetect –y 0
You should see RTC (Real time clock) responding on the address 0x68.
8. Run a test on i2c-1 with “sudo i2cdetect –y 1”
sudo i2cdetect –y 1
If you have PI Cubes I/O Module connected to the Pi Cubes Main board you should see respond on address 0x1C.
Now you have I2C ready on Raspberry Pi to communicate with IO Modules and RTC.