Coding / Programming Videos

Post your favorite coding videos and share them with others!

I2C tutorial in 5 minutes + Arduino & Raspberry Pi implementation. Electronics Crash course # 13

Download Video link >

I2C tutorial in 5 minutes + Arduino & Raspberry Pi implementation. Electronics Crash course # 13

My FREE introduction to robotics course-
Full Video article:
Video Article-

I2C in 3 mins

I2C is a communication protocol that is used to transmit information between electronics. It is used in professional consumer goods, and hobby projects as well.
We can connect 1008 devices within a communication loop and only use 2 wires
It was developed by philips in 1982 to standardized communication between the cpu and peripherals inside its audio and video appliances. Since then the protocol has been periodically updated since then and now can support up to 3.2 megabit speeds
Now lets understand how it works.
Uses 2 wires to communicate information. These are Serial data- SDA, & Serial clock-SCL
It supports multiple devices on one loop and multiple ‘masters’
I2C messages are sent as messages. Now each message is broken into individual frames or segments which are responsible for different things.
First we have the start condition,
Followed by our address frame where i2C sender(master) communicates the recipient of the message (Slave)
Followed by a read/write bit which states if the sender is sending information or receiving information
Followed by the acknowledge bit by the reciver to ensure that the information so far has been successfully received by the intended recipient(slave). Think of roger or copy in military context
Lastly we sent our actual data followed by our stop condition.

what is it up against
• serial- another 2 wire communication protocol. You have probably seen this in your arduino ‘serial monitor’. Serial is asyncronnous which means clock information and this has to be established beforehand. Furthermore Serial doesn’t support more than 2 devices like I2C can do.

SPI is closer to I2C in the sense that you can control multiple devices. However SPI uses many more pins than I2c. Furthermore while SPI is established protocol but not standardized so its implementation might differ from device to device.

What are some downsides
The actual communication and software behind is quite complex however, most of this work is done for us by device manufacturers and open source libraries.
Slower than SPI
Requires dedicated hardware which means you can’t bitbang. Bitbanging is using software to decode signals instead of harware.

What are some positives
I2c doesn’t need dedicated lines to enable each receiver(slave) unlike SPI. This means you can have up to 1008 devices all running with just 2 wires.
Ack bit confirms that data has been successfully received
Standardized protocol makes it plug and play with multiple different electronics.
I2C can have multiple master or transmitting devices within a loop unlike SPI. Look at the pic for more info

Raspberry pi Implementation
The raspberry pi has 2 I2C pins pains- pins (3,5 or 27,28).
To activate I2c, you need to go into raspi-config, then into interfacing options and enable i2c.
Make sure to have the rpi.GPIO python package installed on your RPI
Arduino Implementation
Each arduino board has different I2C pins. The uno uses A4 and A5.
Lastly import the wire library to implement I2C in your code,


Basics of the I2C Communication Protocol

How I2C Communication Works and How To Use It with Arduino




View Comments source >

Transcript view all >

00:00 I Square C is incredibly powerful and

00:05 using these two wires we can connect up

00:07 to 1008 devices within one I Square C

00:11 loop I Square C is a communication

00:12 protocol that's used to transmit

Leave a Reply

Please Login to comment
Notify of
Translate »