Connecting the Arduino to I2C modules | The Communication Blog

Thursday, March 29, 2012

Connecting the Arduino to I2C modules

By Ian Harris


The Arduino microcontroller (as well as nearly all the Ardunio clones) has the power to interface with a wonderfully wide array of parts through the I2C interface.

So what's I2C? Also known as I squared C, it is a protocol that manages communication between a microprocessor (Arduino) and I/O components via a two-wire interface, also known as TWI. In fact, since the I2Cprotocol is so abundant for parts with a two-wire interface, the terms I2C and TWI are typically used interchangeably.

There are so very many different components the Arduino can control (thanks to its inbuilt I2C support), the possibilities are amazing. Gyroscopes, audio amplifiers, humidity sensors, motion detectors, video modules, step motors, digital signal processors, touch sensors, acceleration sensors รข€" and that is just a few. If you're trying to find inspiration for a project, check out these vendor lists for thousands of two wire toys to wire to your Arduino, for example Mouser, RS, Digikey and Element 14.

To help you control your parts, the Arduino kit comes pre-configured with standard libraries. A "standard library" is a hunk of application code that does the hard, boring stuff for you. It suggests the developers of the I2C system (or whatever "duino" clone you're using) have already done the leg work of making the system simpler to tinker with. To explain, the purpose of Arduino isn't to coerce people to build up their own drivers that manage voltage changes, buffering and address assignment. That's no fun. The aim of Arduino is to let the average hobbyist or student start tinkering straight away.

One of these 10 standard libraries is called "Wire" and it's specifically designed to make it easier for you to regulate your I2C/TWI modules. As of the current version of the Arduino libraries, the Wire library inherits from the Stream base class. This means that if you've worked with the Serial, SD and Ethernet libraries, you're already acquainted with the Wire library because they all inherit from the same base class, Stream.

With the standard I2C components you can use Arduino's standard code libraries to speak with them and add this functionality into your new project.




About the Author:



The Communication Blog
Bookmark and Share

No comments:

Post a Comment

 

The Communication Blog Copyright © 2009