3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

I2C between Arduino's

I2C between Arduino\
Ever wanted to connect more Arduino's to transfer data or commands between them?
What purpose? Maybe you don't have enough I/O Pins or Analog In's. Maybe you want to do separate tasks on the same project but still want to communicate between the Arduino's. Or maybe you just need to do a simple thing more complicated. 

There are many ways to send a command to another Microcontroller:

UART -  Requires pins 0 and 1. The problem with UART is that only one device can send data to another. And also it's already in use by the USB port of the Arduino to connect to the computer.

DIGITAL I/O
-  Basically put a pin HIGH and read it on the other Arduino. But with this you have a
limited number of commands and devices.

I2C - I2C Requires Analog Pins 4 and 5 and two pull-up resistors. You can connect more than 100 Arduino's on the same 2 pins. It's simple, reliable and easy-to-use. 



 
Remove these adsRemove these ads by Signing Up
 

Step 1I2C Basics

I2C Basics
I2C is a bit complex in theory. The Arduino environment makes it all simple but anyway, here is a small part of the theory you should know. 

 I2C (pronounced I-squared-C) created by Philips Semiconductors and commonly written as "I2C" stands for Inter-Integrated Circuit and allows communication of data between I2C devices over two wires. It sends information serially using one line for data (SDA) and one for clock (SCL).

Master and Slave

The I2C protocol defines the concept of master and slave devices. A master device is the device that is in charge of the bus. This device controls the clock and generates the START and STOP signals. Slave devices listen to the commands sent by the Master and respond to them.

Basic details:

Transfer rate
: 10 Kb/s (low speed) - 100Kb/s 
SDA - Serial DAta line
SCL - Serial CLock line
128 possible addresses 
16 reserved addresses
112 devices max

Devices have to share both 5V (Power) and GND (Ground)









« Previous StepDownload PDFView All StepsNext Step »
13 comments
Apr 9, 2012. 8:14 PMact casual says:
how do you enable the pull ups
my wire seen it not do it, i have 0022

Feb 22, 2012. 6:55 AMbinibp says:
Can anyone attach de code for master and slave in dis ckt.......de two .pde attachments are not readable.....plz help....plz plz vry urgent....
Sep 11, 2011. 3:07 AMhje says:
In the reference design it says nothing about common ground and Vcc. You can do without :D as it is a 2-wire bus. Otherwise great introduction to the subject.
Jun 3, 2011. 1:59 PMchris911ny says:
I have read in some articles that the wire library will enable internal pull-ups, is that the case or we really need to add pull-ups?
Jan 27, 2011. 1:15 PMjeremyvnc says:
Pins 4 & 5 are SDA and SCLK for I2C
Nov 11, 2010. 4:46 PMWyoJustin says:
Thanks for taking the time to post this! It is just what I was looking for.

Justin
Sep 12, 2010. 10:50 AMeasydaman says:
Nice! Thanks man!
A little sidenote for when working with an Arduino Mega: Comm-Pins are 20 and 21. But well... figuring that out takes 5 minutes. On the other hand: you just saved them ;-)
Sep 10, 2010. 3:40 PMtekkentux says:
Is that pin 3 and 4 (as in the text), or pin 4 and 5 (as in the picture)? Thank you!
Apr 12, 2010. 4:55 PMamando96 says:
 sweet, making an i2c controlled motor driver to learn some of this...
Nov 17, 2009. 2:23 PMsmessud says:
You are right (and I was wrong:().
I mixed I2C and SPI (Serial Peripheral Interface) where you need a chip select per slave.
Thanks for the instructable anyway.

Nov 16, 2009. 10:28 PMfrollard says:
You need to reply direct to a comment or the person won't get notice you wrote a reply.
Nov 16, 2009. 1:03 PMsmessud says:
This is a simple case where there is only one slave.
If you add more slaves on the bus, you need an extra wire per slave (or some multiplexing circuit).
Apart from that, a nice an clear instructable.


Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
4
Followers
1
Author:cornelam