blog.lexruee.ch
Yet another blog on the Web.

In this blog post I summarize how I2C can be configured on the Odroid C1. As mentioned in the last post, I installed a fresh Armbian system on my SBC. So far everything is working fine, except that I2C is not setup yet.

The first step in setting up I2C involves installing the I2C developer tools and the userspace I2C programming library. In any Debian-based system the I2C developer tools are usally available in the package i2c-tools, whereas the I2C programming C library is packaged in libi2c-dev. With the apt package manager we can install these two packages as follows:

sudo apt install i2c-tools libi2c-dev

The next step involves loading the kernel modules i2c-dev and aml_i2c. In short, I2C devices are usually controlled by a kernel driver, so to allow userspace programs to inteface with I2C devices too, we need to load the i2c-dev module. The aml_i2c module, on the other hand, is the I2C driver for the Amlogic ARM CPU S805.

For loading both modules on on every boot, we just have to add the following lines to the file /etc/modules:

i2c-dev
aml_i2c

Lastly, we should add our user to the i2c group so the i2c-tools can be used without having to run them as root:

sudo usermod -aG i2c your-user

At this point, it is proably a good idea to reboot the SBC :-) so the changes can take effect.

After the reboot you should be able to list all the I2C adapter interfaces using the command i2cdetect as shown below:

sudo i2cdetect -l
i2c-1   i2c         aml_i2c_adap1                       I2C adapter
i2c-2   i2c         aml_i2c_adap2                       I2C adapter
i2c-3   i2c         aml_i2c_adap3                       I2C adapter
i2c-4   i2c         aml_i2c_adap4                       I2C adapter

And if you have already connected an I2C device to the first I2C bus, you can use the handy -y option of the i2cdetect command to find out the device's address.

 sudo i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- 48 -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --   

References:

© Alexander Rüedlinger, 2017-2018
Proudly powered by Pelican, which takes great advantage of Python.