I working on a project, I was faced with a challenge of creating a serial bus via multiple Arduino which could communicate with each other. My first intuition, after a little push in the right direction by Tom Igoe, was to create a Master/Slave setup where a Master micro-controller polls all the slave micro-controllers, and dispatches an action. Although this answered one of my question, polling didn’t allow for complete 2-way communication. It tuned out that the answer was mainly an oversight of my interpretation of the Wire documentation.

From Arduino Site:

Wire.begin()
Wire.begin(address)
====
Description
Initiate the Wire library and join the I2C bus as a master or slave.
====
Parameters
address: the 7-bit slave address (optional); if not specified, join the bus as a master.
====
Returns
none

I interpreted this explanation as Wire.begin(SomeAddress) would default as a slave, and not be allowed to be a Master. Being as curious, and stubborn as I typically am, i decided to forget what I thought I was being told, and instead try to break the library, so I could then see where it broke, and attempt to adjust it in a way that better suited my need. Surprise, surprise, it worked, and not need to change anything at all! The address parameter is optional and defaults as a master role if no address is set. However if you do plan on sending messages to the master, you could switch speaker and listener roles via a slaves Wire.onReceive(handler) rather then polling using onRequest(handler).

I then decided to do a search on google for just “i2c”. When I clicked on the Wikipedia entry it all made sense in the first sentence of the entry summary:

I²C (Inter-Integrated Circuit) (pronounced /ˈaɪ skwɛərd ˈsiː/ or /ˈaɪ tuː ˈsiː/) is a multi-master serial single-ended computer bus…

This basically states that no one microcontroller (unless you do not specify an address) could claim being a master at all time. They could be bumped off their soupbox by another microcontrol and assume the role of listener/slave at anytime.

Post to Twitter


Subscribe to comments Comment | Trackback |
Post Tags: , , ,

Browse Timeline


This website uses IntenseDebate comments, but they are not currently loaded because either your browser doesn't support JavaScript, or they didn't load fast enough.

Add a Comment


XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">


© Copyright 2007 unthink media . Thanks for visiting!