United States - Flag United States

Please confirm your currency selection:

Bench Talk for Design Engineers

Bench Talk

rss

Bench Talk for Design Engineers | The Official Blog of Mouser Electronics


Chip To Chip: Tips For Using I2C Mike Parks

Many integrated circuit-based sensors and output devices offer an interface protocol called Inter-integrated Circuit, commonly abbreviated as I2C. There is tremendous value in using I2C-based components in a microcontroller-based solution that can result in a much more streamlined and robust product, especially if you need to interface with multiple external I/O devices. I2C allows you to share a common data and clock bus amongst multiple devices, thus reducing the I/O pin count and the number of interconnecting wires required to get everything communicating. This blog is an attempt to provide some practical tips on integrating I2C into your next application.

I2C is a serial communication protocol that uses two wires, one abbreviated “SDA” for serial data and the other “SCL” for serial clock. A common ground is also needed, though not always depicted in schematics. The benefit of I2C in many embedded applications is to take remote sensor measurements, digitize the value, and send an undistorted digitization of an analog measurement to a microcontroller for further processing. Another common use in the embedded arena is to expand the memory footprint of a system using I2C capable memory chips. Here is a screen capture from a logic analyzer showing a microcontroller communicating to a MCP4725 digital-to-analog converter via I2C.

 

Figure 1: Screen capture from logic analyzer showing SDA and SCL signals of the I2C protocol.(Click to embiggen)

Both the clock and data lines operate on the open drain or open collector principle. Thus a pull-up resistor is required on both lines. Most folks will recommend to start with a 4.7KΩ pull-up resistor and adjust accordingly depending on the devices being connected. As you connect more devices, be sure to reduce the resistor value. Do not attempt to save on component count by using one resistor for both SDA and SCL; it will cause your devices to misbehave. Additionally it is recommend to always use an external pull up resistor even if you are connecting devices that have internal pull-ups and operate at the same operating voltage. If you have components with different operating voltages, you may want to read this article about open collector circuits for insights on how to connect those devices.

Some devices allow you to connect multiple copies of a device by allowing the developer to customize the address of each of the components. Typically this is achieved by connecting address pins to Vcc or ground in different combinations. For example, if a device has three address pins (A0, A1, A2) you can connect up to 8 identical devices. The I2C protocol allows for up to 127 devices to be connected, notwithstanding the limitation caused by requiring devices to be uniquely addressable. In other words, you may not be able to actually connect 127 copies of the same device. Realize, however, that as a rule of thumb wires connecting I2C devices should not exceed 6 feet in length to ensure reliable performance.

Figure 2: Open Collector Topology Used By I2C Circuits

Let us know in the comments down below which I2C devices you like to use in your embedded electronics projects. *** All circuits were done in the new MultiSim BLUE from Mouser and NI. Check it out at www.mouser.com/MultiSimBlue.



« Back


Michael Parks, P.E. is the co-founder of Green Shoe Garage, a custom electronics design studio and embedded security research firm located in Western Maryland. He produces the Gears of Resistance Podcast to help raise public awareness of technical and scientific matters. Michael is also a licensed Professional Engineer in the state of Maryland and holds a Master’s degree in systems engineering from Johns Hopkins University.


All Authors

Show More Show More
View Blogs by Date

Archives