A Single Script to Setup I2C on Your Raspberry Pi

I2C is a data bus that uses two bidirectional lines (SDA and SCL) to connect multiple peripherals to computers and embedded systems. The GPIO 2 and 3 on Raspberry Pi could be used as the SDA and SCL lines for I2C devices. There are many I2C devices could work with your Raspberry Pi, but they are not “plug and play” since Raspberry Pi doesn’t enable I2C by default. You can, of course find some great tutorials on the Internet to enable I2C step by step, such as this one and this one. It is not a difficult task and will not take long time to get it done.
I would like to share a script that could have all these configurations done. This script is extracted from Witty Pi‘s software installing script, and it is proven to work well. This script will enable I2C on your Raspberry Pi and install i2c-tools (if it is not installed yet).

You will need to have your Raspberry Pi connected to the Internet, and use “sudo sh setup-i2c.sh” to run this script.

See also