Thursday, 15 April 2010
Basics of I2C™
The I2C bus allows you to connect several peripherals to one or more master controllers.
In this diagram the controller is an Arduino; it is connected to a port extender and an LCD display.
One commonly used port extender can drive up to 8 i/o lines; you might use four lines to control LEDs, and four lines to read push-buttons. It's a simple IC chip which costs about £1. All you do is connect it to ground, to a 5 volt power source and to the two data lines that form the I2C bus. The Arduino has a Wire library which allows you to turn the output lines on or off, and to read the state of the input lines.
A commercial I2C LCD display is a bit more expensive (about £30). I built my own using a cheap serial LCD module (about £7) wired up to a port extender. I drive it using a modified Arduino library which someone else wrote for a slightly different port extender chip.
The Arduino supports the original version of the I2C protocol which allows me to connect up to 127 different devices to a single controller. That means that I have plenty of spare capacity. Over the next few days I plan to add a controllable voltage source, a programmable voltmeter and a simple logic analyzer, at a cost of about £30.
The Arduino can easily communicate with a PC over a USB cable. I'm planning to hack a simple Python app which plots voltage values in real time - a minimalist oscilloscope.