Here's my objective: Option 1: 2 Slaves, 1 Master One slave (Slave A) has buttons connected to it, and reads high/low state. It needs to send a message via i2c immediately to the Master. The Master then tells the other slave, Slave B, to turn an LED on or off via i2c. In short, there needs to be bi-directional communication, and ideally it would be immediate.
From what I have read, it sounds like I can have the Master poll Slave A with the wire.request. The slave either responds with nothing back (which seems to respond with ⸮), or it tells them that a button has been pushed. The Master then sends a standard wire.write message to Slave B and it lights the LED.
My first set of questions are:
1) Does it matter how often or quickly the Master polls Slave A? 2) Can you clog up the i2c lines with too many polls? 3) Does it have any detrimental effect on the hardware, by overworking it? Would the arduino's lifespan be shortened as a result of so much i2c communication?
OR Option 2: 3 Slaves It seems like another option is to have 3 slaves, which sounds like no one is a fan of for some reason. The appeal of the multiple slaves and no master is that you can have Slave A immediately send the message to Slave C (the Master in the first scenario), without a Master having to poll the Slave A.
I tested having two Slaves with addresses '8' and '9'. They both sent messages to each other, no problem. Nick Gammon shows this as a possibility in example code also: http://www.gammon.com.au/i2c-summary If you go to the 'Communicating with other devices' section, it shows his 'master' as having an address of 25. From what I understand, this actually makes it is a 'slave.'
Regardless, it does work for me to have two Slaves send messages to each other. The only thing I can guess could be a problem is if either Slave A, B or C decides to send a message at the same time. I have not been able to get this to occur in my tests yet. But out of curiosity:
4) What would happen if two slaves talk at the same time and the i2c trips over itself? 5) Does it only ruin the two messages sent at the same time? Or does it crash the arduino, and require a restart???
I am guessing that the master's primary purpose is to make sure that messages don't get sent at the same time. Is there something else I am missing?
Thanks for the input! :)