I have an architecture like this:
Master - It contains an RF communication chip. All nodes rely on Master to receive and send data to a central unit.
Node - It has some basic GPIO functionality. There can be 4-5 different types of nodes, each requiring a different GPIO count. For the sake of design simplicity, I am planning to throw a cheap microcontroller on each node and handle all GPIO locally. That way I just need a pre-defined control data packet from the master to do any task. Similarly, the node will send a pre-defined packet which the master will understand. The packet definition will contain the node type.
Nodes can change in number and preferably should be hot-swappable. Communication works like this:
Two nodes do not communicate directly.
Master can have a data packet which it wants to send to any particular node.
Any node can have a data packet which it wants to send to the master.
Max distance between a node and master will be less than 50 cm.
After some thought, this is the plan I came up with:
Make all nodes communicate over i2c. 16 nodes per master seems to be a good number so I can put a 4 bit DIP switch to set the i2c address of each node. Basically I will be doing a digital read on 4 gpio and setting the address accordingly.
This will be perfect when master wants to read or write data to the nodes.
For the time when node wants to send data, I need to have an additional GPIO per node which alerts the master that some data is present. Alternatively, I can keep reading all nodes in the loop and keep checking if some data is available.
Is there a better solution to this problem?