Arduino

What is an I2C bus in Arduino?

Making projects using Arduino can get messy sometimes as there are a lot of wires tangled up with each other making it difficult to interpret the connections of Arduino pins and other peripherals. Also, if the number of devices attached with Arduino is large then there is a probability that you might run out of pins soon.

So, to avoid that an I2C bus can be used that just uses two lines to communicate, one for data and other for synchronizing the clock. Every Arduino microcontroller comes with an I2C communication protocol, so we have explained deeply what is I2C protocol and how to use I2C to save pins of the Arduino.

What is I2C bus in Arduino

I2C is a communication protocol for serial communication between the devices or it can also be termed as a two-wire communication as it uses two line for communication that are :

SDA : The line responsible for transferring and receiving the data of the device connected with each other and cna do one thing a time either receiving or transferring the data

SCL: The line that is responsible for synchronizing the clock of both the devices to ensure faster data rate.

Data rate for I2C

The default rate for data transfer of the I2c communication is between 100 to 400 KHz

Key uses of I2C protocol

Following are the major reasons of using the I2C over the SPI:

  • Lesser number of pins or connection are required
  • Easier to use and work with
  • You can make multiple master and infinite slave system
  • Compatible will all the Arduino microcontroller boards

I hope the concept of I2C bus is clear now so let’s talk about how you can use the I2C protocol in Arduino and what is the significance of it.

Every Arduino board comes with the dedicated I2C pins that are mainly labeled as SDA and SCL but if they are not labeled then by default the pin A4 and A5 can be used as SDA and SCL. For your knowledge I have given the I2C pins of the most commonly used Arduino board by the students and engineers in the table below:

Board name SDA and SCL pin number
Arduino Nano A4 and A5
Arduino Mega 20 and 21
Arduino Leonardo A4 and A5 and pins next to AREF pin
Arduino Uno A4 and A5 and pins next to AREF pin
Arduino micro 2 and 3

To connect the peripherals that have any dedicated ports for the SDA and SCL you connect them using Arduino SDA and SCL pins and can use them as you want.

Next you can combine two or more Arduino boards to operate different devices by creating one Arduino board as master and others as slave. By doing such practice you can connect a comparatively large number of devices with Arduino and can control them quite easily.

However, you can also use these I2C Pins of a single Arduino to connect multiple devices with it and for the devices that do not have I2C pins and consumes a considerable number of pins of Arduino, for them I2C modules are available in the market. To connect with Arduino using the I2C module the device is first connected with the I2C module and then from there the SDA and SCL pins of the module are connected with the I2C pins of Arduino microcontroller board.

The main purpose or significance of using these I2C pins of the Arduino is to accommodate more devices with a single Arduino board. As in the past it was difficult to connect large numbers of devices with microcontrollers, so Arduino was introduced to make it easy and for now to save the pins of the Arduino I2C protocol is mainly used.

Conclusion

Connecting your devices with Arduino using the I2C bus or pins of the Arduino can save you some pins of the Arduino that you can use from any other useful purpose. So, we have explained what I2C is and how you can use it with Arduino to connect various devices with it.

About the author

Aaliyan Javaid

I am an electrical engineer and a technical blogger. My keen interest in embedded systems has led me to write and share my knowledge about them.