Skip to main content
shopping_basket Basket 0
Login

I2C Protocol Basics with YouTube tutorial

EngineeringMD
2

If you've ever tried making your own electronics projects, chances are you've come across the I2C protocol. For me, I normally encounter it when I need to interface sensors with my microcontroller. This is exactly what I explained in the video above. I suggest watching the video first and then come back here and I'll explain some parts in more detail. - would be awesome if you give a thumbs up and subscribe!

I wanted to do the project because Covid-19 has become so widespread and I wanted to reduce the risks for those who have to manually check other people's body temperatures. So I did my research and found the MLX90614 non-contact temperature sensor. Then I thought 'why not make videos about this too?', so here we are. 

I2C, in a nutshell, lets the electronic devices talk to one another. There is a main device, which initiates and controls communication, for example, a microcontroller, and there is a secondary device, which has a specific operation like sensing temperature and reports this data to the main. 

The devices are connected via a 2-wire bus - the serial clock (SCL) and serial data (SDA) lines. 

The serial clock carries the clock signal which makes sure the main and secondary are in step with each other for every bit that is transferred. The bits which have meaningful information are transferred via the serial data line. 

The main can speak to the secondary by sending the ADDRESS of the secondary on the SDA line. This is the same when there are many secondary devices on the bus. Every secondary device will have its own programmed address, each consisted of 7 bits. 

2= 128, hence there can be 128 devices on the bus. However in practice only around 112 is the limit because the other address values are 'reserved'. 

The photo above shows how several devices are connected on the i2c bus. Note that the SDA and SCL lines each need pull up resistors.

Here's a simple formula for calculating the minimum pull up resistance:

R= (VDD – VOL) / IOL

The values can of VDD, VOL, IOL can be taken from the device's datasheet. Normally the pull-up resistance is 4.7-10k ohms. 

Another limiting factor is the maximum bus capacitance. The rule of thumb is to keep the bus capacitance below 400 pF.

The standard speed in I2C is 100 kbps but can go up to 5.4 Mbps. 

Each I2C message contains:

  • Start condition
  • Address of the secondary
  • Read and write (R/W) bit 
  • Data frame
  • ACK/NACK bits
  • Stop condition

There will be a part 2 video where I will be programming the main device to communicate with the MLX90614, and similarly, a DesignSpark article/project will be made available which will tackle the details of the I2C message more so stay tuned!

Aiming to help students and young engineers develop their skills through YouTube content! :) https://www.youtube.com/channel/UC2OruHstUk7AwQV4Riw20Zw

Recommended Articles

Comments

September 30, 2020 14:46

Thanks for a very clear presentation, will keep for reference.

September 2, 2020 14:50

Well Presented . I could use this with students

DesignSpark Electrical Logolinkedin