I2C

From ArchWiki

I²C or I2C (Inter-IC) is a synchronous, multi-controller/multi-target (controller/target), packet switched, single-ended, serial communication bus invented in 1982 by Philips Semiconductors.

It is used by many hardware boards to communicate with general purpose I/O (GPIO) devices.

A similar extension of I2C is SMBus which is more specifically used for hardware monitoring purposes.

Installation

I2C kernel modules already exist in most default kernel packages.

Userspace tools can be installed from i2c-tools. Bleeding edge is on i2c-tools-gitAUR.

SMBus-specific tools can be installed from lm_sensors.

Module loading

In some cases it might be required to load the module at boot:

/etc/modules-load.d/i2c-dev.conf
i2c-dev

Depending on your system and usage, other hardware-specific modules such as i2c_i801 or i2c_smbus might have to be loaded as well.

If the modules are properly loaded, you should see the /dev/i2c-* devices.

Permission for using the /dev/i2c-* devices can be granted by adding the user to the the i2c user group.

Usage

i2cdetect can detect all the active I2C devices:

$ i2cdetect -l
i2c-0	i2c       	Synopsys DesignWare I2C adapter 	I2C adapter
i2c-1	i2c       	Synopsys DesignWare I2C adapter 	I2C adapter
i2c-2	i2c       	Synopsys DesignWare I2C adapter 	I2C adapter
i2c-3	i2c       	Synopsys DesignWare I2C adapter 	I2C adapter
i2c-4	smbus     	SMBus I801 adapter at f040      	SMBus adapter
i2c-5	i2c       	i915 gmbus dpb                  	I2C adapter
i2c-6	i2c       	i915 gmbus dpc                  	I2C adapter
i2c-7	i2c       	i915 gmbus misc                 	I2C adapter
i2c-8	i2c       	AUX B/DDI B/PHY B               	I2C adapter

When an I2C device is connected to a known bus, i2cdetect can probe it for active addresses:

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

See also