I2C device addressing

johnA:
The link I gave clearly shows that it is possible for an Arduino to be both Master and Slave at the same time (unless that guy was throwing some BS out into the ether).

That would be me, I think. :slight_smile:

You sound like you must be my age or thereabouts.

Can you define the problem more clearly? You want multiple slaves running the same software. So far so good. Are you gradually going to add them? You could have some sort of "give me an address" button that, when pressed, asks the master for a free address, and then writes that into EEPROM.

The master could do a broadcast (address 0). I'm not too clear about whether multiple slaves of the same address would cause a problem there, but I suspect not (need testing to confirm).

The broadcast could be "any slaves need an address?". The slaves could then wait a random time and then respond. Hopefully one will get in sooner and be assigned an address before the others respond. I think it is achievable, but there might be simpler ways. Like, a simple program that writes a slave address to EEPROM before deploying the "main" program.

Remember, you don't have heaps of program memory. You don't want to take half of it up with a smart "address allocation" routine if there are simpler ways.