I2C: How it works and how to use it?

I2C is one of the communication protocol which is often used for data transmission between micro controllers and peripheral devices.

This article explain how i2c works and how to use it.

Table of Contents

  1. What is I2C?
  2. Overview of I2C
  3. How I2C works
  4. How to use I2C

What is I2C?

I2C(Inter-Integrated Circuit)is a de facto standard developed by Philips Semiconductors (NXP Semiconductors).

I2C is often used in communication between micro controllers and peripheral devices (such as EEPROM).

I2C is pronounced as “I two C” or “I squared C” and sometimes written down Inter-IC.

The specification of I2C is published by NXP Semiconductors as the name of UM10204 I2C-bus specification and user manual (registration required).

I2C is de facto standard as famous as SPI that is implemented all over the world.

Overview of I2C

I2C uses two signal lines: SDA and SCL.

SDA is the abbreviation of Serial Data, which is for data exchange.

SCL is the abbreviation of Serial Clock, which is for sharing clock signal.

Each lines requires pull-up resistors.

In I2C communication, devices are divided into master and slave.

Master begins communication, generates a clock signal, and terminates communication.

Master can communicate with a slave by specifying the slave address which is unique to devices.

Example of the behavior of master and slaves

Whn master transmits data to slave:

  1. Master begins communication.
  2. Master specifies a slave address.
  3. Master transmits data to the slave.
  4. Master ends communication.

When master receives data from slave:

  1. Master begins communication.
  2. Master specifies a slave address
  3. She slave transmits data to the master.
  4. Master end communication.

How I2C works

Data transmission

SDA and SCL will work when transmitting data:

Example of transmitting 9A in hex (10011010 in binary)

The voltage statuses of SDA when SCL=HIGH are received as data.

Thus, changing the voltage status of SDA when SCL=HIGH is prohibited.

Start and stop communication

To tell the beginning and the end of communication, master generates START Condition and STOP Condition.

When SCL=HIGH, SDA changes:

  • HIGH -> LOW, START Condition
  • LOW -> HIGH, STOP Condition

Communication between master and slave begin with START Condition and end at STOP Condition.


If the receiver receives data without error, it returns acknoledge (ACK) to the transmitter.

If the receiver detects errors while receiving data, it does not return ACK. This is called not acknoledge (NACK)

Byte format

I2C format is as follows.

  1. Master generates START Condition.
  2. Master broadcast slave address (7 bits).
  3. Master transmitts R/W bit.
  4. Slave specified with slave address returns ACK.

If R/W=0 (transmission from master to slave),

  1. Master transmits data (8 bits)
  2. Slave returns ACK.
  3. Return to 5 or master generates STOP Condition.

If R/W=1 (transmission from slave to master),

  1. Slave transmits data (8 bits).
  2. Master returns ACK.
  3. Return to 5 or master generates STOP Condition.

Slave address and data are both transmitted by MSB first.

How to use I2C

An example of using EEPROM by I2C is here.


This article explained how I2C works.

Shopping Cart