# Inter Integrated Circuit

> I²C (Inter-Integrated Circuit), pronounced I-squared-C, is a multi-master, multi-slave, single-ended, serial computer bus invented by Philips Semiconductor (now NXP Semiconductors). It is typically used for attaching lower-speed peripheral ICs to processors and microcontrollers. [Wikipedia](https://en.wikipedia.org/wiki/I²C)

* [Linux Journal Greg Kroah-Hartman I2C Drivers Part I](http://www.linuxjournal.com/article/7136)
* [Linux Journal Greg Kroah-Hartman I2C Drivers Part II](http://www.linuxjournal.com/article/7252)

### Required Hardware

One I2C sensor

## Kernel Integration

### Kernel Display Message

```bash
    root@edison:~# dmesg | grep -i i2c
    [    0.190675] I2C bus = 1, name =      pcal9555a-1, irq = 0x 0, addr = 0x20
    [    0.190711] I2C bus = 1, name =      pcal9555a-2, irq = 0x 0, addr = 0x21
    [    0.190743] I2C bus = 1, name =      pcal9555a-3, irq = 0x 0, addr = 0x22
    [    0.190774] I2C bus = 1, name =      pcal9555a-4, irq = 0x 0, addr = 0x23
    [    0.746686] i2c /dev entries driver
```

## Userspace Interfaces

### SysFs

```bash
    root@edison:~# ls /sys/class/i2c-dev/
    i2c-1  i2c-2  i2c-3  i2c-4  i2c-5  i2c-6  i2c-7
```

### DevFs

```bash
    root@edison:~# ls /dev/i2c-*
    /dev/i2c-1  /dev/i2c-2  /dev/i2c-3  /dev/i2c-4  /dev/i2c-5  /dev/i2c-6  /dev/i2c-7
```

### ProcFs

```bash
    root@edison:~# cat /proc/interrupts | grep i2c
      7:         44          0   IO-APIC-fasteoi   i2c-    designware-1
     10:          0          0   IO-APIC-fasteoi   i2c-designware-2
     12:          0          0   IO-APIC-fasteoi   watchdog, i2c-designware-3
     13:          0          0   IO-APIC-fasteoi   i2c-designware-4
     14:          0          0   IO-APIC-fasteoi   i2c-designware-5
     15:          0          0   IO-APIC-fasteoi   i2c-designware-6
     16:          0          0   IO-APIC-fasteoi   i2c-designware-7
```

## Applications / Libraries

### Setup

#### Opkg

```bash
    root@edison:~# opkg install i2c-tools
    Package i2c-tools (3.1.1-r0) installed in root is up to date.
    ...
```

### Programs

#### i2cdetect

```bash
    root@edison:~# i2cdetect -y -r 1
         0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
    00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
    10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
    20: UU UU UU UU -- -- -- -- -- -- -- -- -- -- -- -- 
    30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
    40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
    50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
    60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
    70: -- -- -- -- -- -- -- --
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://theiotlearninginitiative.gitbook.io/embedded-linux/subsystems/inter-integrated-circuit.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
