What Is I2C?

How Does I2C Communication Work?

Each gear connected to the I2C bus has a unique address that identifies it during communication.

Two Arduino boards

Communication is initiated by the master unit, and incorrect addressing of slave devices can cause errors in transfer.

Check out our in-depth guide onhow UART, SPI, and I2C serial communications workto give you some context.

Devices that operate at different voltage levels can still communicate effectively with the help of voltage shifters.

I2C communication demonstration

Image Credit:Arduino I2C documentation

This means that devices operating at 3.3V need voltage shifters to connect to a 5V I2C bus.

It uses two pinsSDA and SCLon the Arduino board for I2C communication.

The Wire library provides functions to initiate communication with an I2C unit, send data, and receive data.

Arduino I2C Uno pins

Connect the pull-up resistors between theSDAandSCLpins and the5Vpower rail on the breadboard.

Finally, connect the two breadboards together using jumper wires.

Then use theWire.read()function to get data from the slave equipment.

Arduino nano I2C pinout

The master board can then read the value we sent, then display it on the serial monitor.

Use the following code to identify any slave devices address present on the I2C bus.

Arduino_I2C connection on a breadboard

nano33BS_06_illustration for I2C communication protocol

Image Credit:Arduino I2C documentation

DHT11 I2C example with 2 Arduino boards