Hi, I have two Arduino nano board connected via an I2C connection on analog pins 4 and 5 with 4.8k pull up resistors connected to the 5V rail. Now i am using some simple code to send a character string between the two Arduinos:

Apparently you only need wire.begin and wire.end if you are sending master->slave messages which I'm not. That's why the wire.begin function takes an address. The master node does not have an address so i can't use the wire.begin function... Can someone confirm this?

I did read the examples. And thanks for the help, according to the documentation the beginTransmission takes an address, it was never mentioned that it can be used without, so i assumed it wasn't overloaded to not take an address for the case of a slave->master transfer. I will try the request handler now, i assumed there must be something i'm missing to detect the request of the master. Thanks everyone for the help!

It is my understanding that the Master controls everything. The Slave can not push data to the Master, the Master must request data from the slave.That is why the Master does not have an address. The Master knows who he is.Also one slave can not push data to another slave. The Master must always be in the middle.

Since the Slave must respond to the Master in the Masters time frame, there are interrupt service routines that the Slave sets up so the Slave can do productive work but still respond to a request from the Master.

But Nick,If you have multiple masters and one master wishes to communicate with another master. Isn't the second master going into 'slave' mode? In that case the node is idle as a slave, waiting to respond to a master. But if it needs something from another node, it can go into master mode to control the dialog.

RandallBTW: You have probably forgotten more about this stuff than I have learned. Thank you for you contributions.

But Nick,If you have multiple masters and one master wishes to communicate with another master. Isn't the second master going into 'slave' mode?

I have an example of multiple masters here:

http://www.gammon.com.au/i2c

See the Atmega328 datasheet page 218:

Quote

21.4 Multi-master Bus Systems, Arbitration and Synchronization

The TWI protocol allows bus systems with several masters. Special concerns have been taken in order to ensure that transmissions will proceed as normal, even if two or more masters initiate a transmission at the same time.

(TWI being the same as I2C more or less).

If multiple devices register a slave address then they can be addressed by any other device. So you might have "slaves" 2, 3 and 4. Now device 3 can "call" 2 or device 2 can "call" 3.

At the moment when you do the Wire.endTransmission() call, the device doing that attempts to initiate a transfer (ie. become the master) and if possible, send the data. When complete, it goes back into "slave" status. So effectively every one can be a master and a slave.

This is made possible electrically because each device has the two wires as high impedance (input) until such time as they attempt to become the master.

Please post technical questions on the forum, not by personal message. Thanks!