Your trying to wish that I2C was a more powerful protocol then it is.
Well yes, but less like wishing and more like hacking.
The reason I think it is even possible is that the slave devices here are Arduino's and not simple chips. This opens some possibilities. For example:
- the Arduino can be both a Master and a Slave at the same time. Gammon Forum : Electronics : Microprocessors : I2C - Two-Wire Peripheral Interface - for Arduino
- there is bus arbitration in the I2C spec when there is more than 1 Master
Therefore it might be possible (within the defined I2C spec) to do the following:
master is also a slave at reserved address 01
all slaves start using reserved address 02, or the address saved in its EEPROM (03 to 120)// see if any slaves are unallocated
master: send a broadcast - Start Allocation message
all slaves with address 02: delay for random number of microseconds
slaveA (as master): creates a 32-bit random number and sends it to master 01
master 01: associates the random number with next free address
slaveB (as master): creates a 32-bit random number and sends it to master 01
master 01: associates the random number with next free address
... repeat until some_magic_condition occurs...// Assign the addresses
master: send a broadcast - Start Assignment message
master: broadcasts slaveA's random number and address
slaveA: sets it's address to the given address; saves the address in its EEPROM
master: broadcasts slaveB's random number and address
slaveB: sets it's address to the given address; saves the address in its EEPROM
... repeat ...// do it again, just in case
master: send a broadcast - Start Allocation
no slaves with address 02 should remain
if there are any remaining, then this step should allocate them
... repeat until some_magic_condition occurs...// enumerate the slaves
master: this should catch both the newly allocated addresses plus the previously saved addresses.
Looks clunky but might work...
John