I Love I²C

I²C is a standard protocol for connecting various electronic parts to a microcontroller. It is pronounced “eye squared see” and stands for Inter-Integrated Circuits. To connect an I²C part you only need to use two pins on the micro (besides Vcc and GND), one for data and one for the clock signal. I²C’s main claim to fame is that many additional I²C parts can be hooked to the same two pins in a daisy chain manner. With a wide variety of I²C parts available from many manufacturers (sensors, LCDs, motor controllers, etc.), you may be able to use I²C parts in many of your designs.

My favorite microcontroller boards are the Arduino and the Photon but most other boards also support I²C. Software libraries are available which make writing the software for I²C parts relatively easy. In many cases a few lines of code will allow you to read a temperature sensor or display information on an LCD display. With a quick Google search you can usually find code snippets for most I²C parts.

There are a few shortcomings of I²C. My main pet peeve is that there is no consistent connector being used by most manufacturers of microcontroller boards or I²C peripheral boards. Personally, I have adopted the Grove 4 pin connector used by SeeedStudio. The connectors cost fifteen cents and you can buy them and pre-made cables in a few lengths from SeeedStudio or Mouser. I’ve listed some of them at the bottom of this post.

A limitation of I²C is that it can only be used for short distances. It will reliably connect parts that are less than a meter apart, which works well for most of my projects where everything is contained in a small box. If you need to go longer distances you will have to pay attention to the capacitive loading on the wires and try to reduce any stray pickup on the I²C wires.

I²C is a reasonably fast interface, but it may not work when very high speeds are needed. Most parts will work with a clock rate of a least 100 KHz, which means an address byte and one data byte can be transmitted in about 200uSec. You won’t be able to transmit audio or video, but for most embedded applications I²C will be plenty fast.

Debugging I²C circuits can usually be accomplished with a low cost oscilloscope by looking at the clock and data lines. For more advanced debugging, the bus pirate is a low cost device that will let you see exactly what is happening on the bus. Most logic analyzers also will decode the I²C signals and display the data in a user friendly manner.

Nearly every project I build uses I²C. If you haven’t used it before, consider spending a little time with it and I think you will be in love too.

Resources:

Photon Board

Photon Board

Grove cable

Grove cable

Grove Cables

Grove Cables

Grove Connector

Grove Connector

Posted in electronics
Tags: