I’m designing devices that will be communicating via the I2C protocol. One of the shortcoming of I2C is that it can’t do an auto discovery of slaves and I want to build something where the end user doesn’t need to figure out how to set addresses on the slaves. So I’m trying to figure out some way of doing slave discovery on a network and came up with the following idea. I’m hoping you guys can help me figure out if this will work, what have I forgotten or overlooked, caveats, etc., etc.
The I2C slaves will always come up with an address of 0x00 and won’t do anything till told. By pushing a button, they will then join the network with that address and wait. Pushing a button on the master will put it in discovery mode (for a set amount of time, say 15 seconds). During this time, it broadcasts only to address 0x00. If it receives an ACK, that means there’s a slave on that address. At that point the master will send a new address (> 0x00) to that slave and it gets stored in an array on the master. The slave receives the address and reconfigures itself to use that new address. Subsequent slaves all get a new (incrementing) address from the master.
the slaves, when first powered up, will not respond to address 0x00, not till a button on them is pushed, therefore enabling them to join the network with address 0x00.
the slaves, when suffering a power loss, will forget their address and will come back up as 0x00 next time they are powered up.
the master will only go into discovery mode when told to by a push button
the master, when entering discovery mode, will check it’s own array first to see if there aren’t slaves already configured. If so, it continues to increment the address from the last slave in it’s array.
the master, during discovery mode, will keep a record of all the slaves it has discovered
the master, when suffering a power loss, will forget all of this and start without any knowledge of slaves upon power up
the master, when in discovery mode, will reset its 15 second timer each time it configures a new slave. This is so that it has time to continue configuring new slaves in case there are a bunch of them that can’t all be configured within the allotted time. After 15 seconds it exits discovery mode and returns to it’s normal routine.
And with this being a specific, custom design, I don’t plan on adding anything to the network with address 0x00, so technically there shouldn’t be any issues there.
What am I forgetting?