Category:I2C Library

Purpose
I2C is a multi-purpose, multi-master bus for communications between integrated circuits. It is a 2-wire serial interface commonly used in embedded systems.

The Pinguino I2C library allows for your programs to communicate over this bus/protocol.

Functions
See under Pages in category "I2C Library" below.

7-bit I2C Addresses
The majority of I2C devices use 7-bit addresses, although there is a variety of ways in which the addresses are quoted in the various device data sheets.

Where 7-bit I2C addresses are used the Pinguino I2C library assumes that the 7-bit address occupies the 7 most significant bits of an 8 bit byte and that the least significant bit, which is used for Read/Write (R/W) indication, is 0 (zero) i.e. the address used is the write address of the device, X X X X X X X 0, where the Xs represent the 7 bits of the I2C address. You will need to consult the particular device datasheet to make sure that you have the I2C address in the correct format.


 * For example the PCF8563 Real-time clock calendar product data sheet quotes a write address of A2h and a read address of A3h. Since the write and read addresses differ by 1 (one) and they are both > 0x7F the required address is 0xA2.


 * Similary, the Bosch BMP085 Digital pressure sensor data sheet quotes a write address of 0xEE and a read address of 0xEF so the required address is 0xEE.


 * However, the Bosch BMA180 accelerometer data sheet quotes two address 40h and 41h, but on further examination of the datasheet it is clear that these two addresses correspond to different settings of one of the device pins and do not include the R/W bit so the required address will be either 0x80 or 0x82 depending on the setting of the device pin.

10-bit I2C Addresses
For a 10-bit address, the address is used "as is" without including a R/W bit. This may seem inconsistent with how the 7-bit address is dealt with, but is due to how 10-bit addresses are specified in the I2C specification.

Known Bugs/Limitations
The current implementation of the 8bits / I2C library (April 2014) allows

- single master operations with peripheral  slave devices as PCF8574, PCF8593, DS1307, etc...(not MCU)

- single master operations with a slave MCU

Other Comments/Suggestions
Corrections, suggestions, and new documentation can be made directly on this Wiki