Hello everyone, after a bit of thinking and playing around with IoT, I've created a very simple mesh-type network layer sitting on top of the RF24 library. I wanted to get it working to ensure my concepts were sound, then see what other people had to say to improve on it. I created this mainly for my own amusement, but with a practical purpose (somewhere down the line) of creating a very reliable and redundant IoT base. Be warned, if you look at the code you should see that I'm more of a BASIC sort of programmer, there are some ugly labels in there and I've completely ignored the usefulness of classes in favor of absolute simplicity. But in my defense, this is just the first working version of it all. Comments, improvements, criticism are welcomed.
github README.md:
RF24 based sensor-mesh (flood, addressless) network
*****This uses the modified RF24 library available here GitHub - gcopeland/RF24: Arduino driver for nRF24L01. You'll need to replace your RF24 library with this one to compile (this fork adds broadcast capability, and also claims minor performance improvements, various bug fixes, not exactly drop-in compatible so be warned).
Most of this was implemented using the original RF24 driver available here RF24: Driver for nRF24L01(+) 2.4GHz Wireless Transceiver
Some ideas and code were also taken from this project GitHub - mic159/ArduinoMesh: A wireless mesh network platform on arduino using the NRF24L01 modules. Work in progress.
It operates using broadcasts and as such does not use or need any addresses.
It is structured as follows:
[nodes >-> relay mesh >-> base]
Nodes only talk to relays, relays talk amongst each other, and also the talk to the base.
The relays create a mesh network amongst themselves. They broadcast every message they receive to every other relay. With this layout, only one relay has to be within range of the base, and each relay only needs to be within range of one other relay. The relays don't have addresses and broadcast blindly to each other. Logic is setup to prevent infinite rebroadcast loops between the relays.
Nodes broadcast their messages to relays, but not to each other. If more than one relay can listen to a node, each relay will re-transmit that reading along to the base, creating a bit of redundancy. Nodes have delivery acknowledgment.
The base potentially receives multiple copies of the same node message and only accepts the first instance of it.
ADVANTAGES:
-simple to setup.
-no addresses needed.
-nodes can be eliminated in favor of an all relay network.
-small, under 8k. Could get smaller with some tinkering (remove printf from RF24)
DISADVANTAGES:
-relay messages flood the network. The number of messages (should be) (number of relays)^2. So with a large number of relays, a huge amount of traffic is generated.
-The logic to stop infinite relay loops probably needs to be worked on more. It is very simple at this point and probably the most likely point of failure.
-At this time, no acknowledgement of [relay >-> base]messages.
-At this time, one way communication only.
To get this working, the most straight-forward setup is with three boards. Burn node, relay, and base to each and they should all start talking to each other. Other possible setups would be two or more relays, or relays and a base. There is some testing code in the relays to send out a broadcast (look at the bottom for Serial.read), negating the need for a node.