This tutorial shows how to set up I2C on a Raspberry Pi so that an I2C device can be used with the Wolfram Language. Note that while these commands must be run as root, the Wolfram Language does not have to be run by the root user to use I2C if using the latest Jessie release of Raspbian.
Enabling I2C Kernel Modules
Next, the I2C Linux kernel modules must also be enabled at boot for the bus to be accessible from the Wolfram Language.
The following kernel modules must be loaded for all Raspberry Pi boards.
To load the kernel modules, append the names of the kernel modules to the file /etc/modules with an editor such as nano or gedit, and reboot.
Alternatively, the modules may be loaded manually with modprobe with the following commands.
Furthermore, on some Raspberry Pi models, there is a blacklist file that prevents the I2C kernel modules from running, regardless of whether or not it is enabled via the previous step.
This blacklist is present on the Raspberry Pi 2, but depending on the specific distribution installed on the machine, this file may also exist on other board models.
The blacklist file is located in /etc/modprobe.d/raspi-blacklist.conf, and if the following line is present, it will need to be removed from the file or commented out with a # character at the start of the line.
Adding Device Tree Parameters at Boot
The I2C device tree parameters must be added before I2C is usable on the system.
This is done by editing the /boot/config.txt file on the machine with a text editor such as nano or gedit.
The line to be added is as follows.
After adding this line, the system must be rebooted; however, one should perform the other steps in this tutorial prior to rebooting.
If this is done successfully, there will be a file named i2c-1 in the /dev folder.