I2C / TWI (Two-Wire Interface)

Arduino

I2C / TWI Arduino Diecimila Pinout:

  • Arduino analog input 4 = I2C SDA
  • Arduino analog input 5 = I2C SCL

Example

(From Keith's Electronics Blog - Arduino I2C Expansion I/O)

#include <Wire.h>   // include Wire library for I2C

void setup() {
  // ...
  Wire.begin();   // start Wire library as I2C-Bus Master
  // ...
}

Wire.begin() initializes the Wire library as an I2C master and reconfigures analog pins 4 and 5 as I2C pins. Wire.begin(address) initializes the Wire library with the Arduino functioning as a slave at address address.

Wire library

Wire library will enable ATMEL internal Pullup's. So using additional pullup's with a short bus may not be required, for example interface only a single nearby EEPROM.

I2C

Philips Semiconductors (now NXP Semiconductors) developed a simple bidirectional 2-wire bus for efficient inter-IC control. This bus is called the Inter-IC or I2C-bus. Only two bus lines are required: a serial data line (SDA) and a serial clock line (SCL). Serial, 8-bit oriented, bidirectional data transfers can be made at up to 100 kbit/s in the Standard-mode, up to 400 kbit/s in the Fast-mode, up to 1 Mbit/s in the Fast-mode Plus (Fm+), or up to 3.4 Mbit/s in the High-speed mode. (Description from NXP I2C-bus specification and user manual v3)

TWI (Two-Wire Interface)

TWI is ATMEL's own implementation of a compatible Philips I2C protocol often called "2-wire Serial Interface".

System Management Bus (SMBus)

The System Management Bus (SMBus) is a two-wire interface through which various system component chips can communicate with each other and with the rest of the system. It is based on the principles of operation of I2C. (Description from System Management Bus (SMBus) Specification)

DataSheet

Playground Links

Links