I2C Multi Master Issues

Currently I have Slave attiny with an IR receiver connected to it. From this it emits a byte relating to the button number pressed. This is called from 2 atmega328 uc’s. which changes the LED’s to the same colour on both boards.

My issue is that only one changes at a time, I believe due to the bus of i2c. So, does anyone have any ideas of how I can get round this? Or even a way of getting the atmega328’s to confirm to the slave when it has received the byte.

Thanks!

Your title says multi-master but your description seems more like multiple-slaves-with-the-same-address.

Are you using the Arduino Wire library? That library cannot change between master and slave so it doesn't do well in multi-master setups.

Yes the I2C standard does allow for multiple slaves with identical addresses. The Arduino libraries don't. But I don't see why it wouldn't work.

Can you draw a diagram? A simple pencil sketch photographed with a phone will be good enough.

I've only played with simple I2C stuff only once or twice and never with multimaster. So take this for what it is.

@MorganS To my knowledge, I2C standard has never supported multiple slaves with the same address; I might be wrong though. I also think that you can switch between master and slave mode by using begin() and end().

@blues1143 You should always post your code.

In a multimaster environment where multiple masters talk at the same time, only one will win the bus arbitration and be able to send or receive the data. The one that wins the arbitration should give other masters the time to use the bus. So if endTransmission() returns 0 (success), it should not attempt to communicate over the bus for a short time to give others a chance. The masters that lost the arbitration should retry.

See wire.endTransmission() for possible return values.

It's called "broadcast". There's a couple of special addresses that all slaves may listen to.