Inter-Integrated Circuit (I2C) Protocol
A good way of adding complexity of features to your projects
without adding complexity of wiring, is to make use of the Inter-
integrated circuit (I2C) protocol. The I2C protocol is supported on
all Arduino boards. It allows you to connect several peripheral
devices, such as sensors, displays, motor drivers, and so on, with
only a few wires. Giving you lots of flexibility and speeding up your
prototyping, without an abundancy of wires.
What Is I2C?
The I2C protocol involves using two lines to send and receive data: a
serial clock pin (SCL) that the Arduino Controller board pulses at a
regular interval, and a serial data pin (SDA) over which data is sent
between the two devices.
In I2C, there is one controller device, with one or more peripheral
devices connected to the controllers SCL and SDA lines.
As the clock line changes from low to high (known as the rising edge
of the clock pulse), a single bit of information is transferred from the
board to the I2C device over the SDA line. As the clock line keeps
pulsing, more and more bits are sent until a sequence of a 7 or 8 bit
address, and a command or data is formed. When this information is
sent - bit after bit -, the called upon device executes the request and
transmits it's data back - if required - to the board over the same line
using the clock signal still generated by the Controller on SCL as
timing.
Each device in the I2C bus is functionally independent from the
controller, but will respond with information when prompted by the
controller.
Because the I2C protocol allows for each enabled device to have it's
own unique address, and as both controller and peripheral devices to
take turns communicating over a single line, it is possible for your
Arduino board to communicate (in turn) with many devices, or other
boards, while using just two pins of your microcontroller.
An I2C message on a lower bit-level looks something like this:
An I2C Message
• The controller sends out instructions through the I2C bus on the
data pin (SDA), and the instructions are prefaced with the
address, so that only the correct device listens.
• Then there is a bit signifying whether the controller wants to
read or write.
• Every message needs to be acknowledged, to combat
unexpected results, once the receiver has acknowledged the
previous information it lets the controller know, so it can move
on to the next set of bits.
• 8 bits of data
• Another acknowledgement bit
• 8 bits of data
• Another acknowledgement bit
But how does the controller and peripherals know where the address,
messages, and so on starts and ends? That's what the SCL wire is for.
It synchronises the clock of the controller with the devices, ensuring
that they all move to the next instruction at the same time.
ARDUINO UNO SDA/A4 SCL/A5
I2C Liquid Crystal Displays