Intro: NRF24L01+ Multiceiver Network
If you're here, you probably know basically what a NRF24L01+ device is. If you have a bunch of them, and get them hooked up properly, you can theoretically create a wireless network of Arduinos (or other MC devices). Sounds easy, right? Well, I hope it will be much easier with the help of this Instructable.
If you've been trying to figure this device out, you can pretty well assume that any Sketches prior to 2014 won't work -- that is, they won't verify/ compile due to changes in the Arduino IDE. There's also a paucity of examples that actually demonstrate a network of more than two devices!
Having said that, here are some internet resources that I found exceptionally helpful in my own quest to build a NRF24L01+ multiceiver network:
(Giving all due credit)
This wiki is affiliated with Yourduino.com and has terrific general info on the NRF24L01+. This is the place to go to learn how to make all the proper hardware connections.
You can get your hardware here, of course! The wiki (first link) makes clear that the NRF24L01+ needs good 3.3 V power -- more than what most off the shelf arduinos are designed to provide. The YourDuino RoboRed has a robust power supply that can handle these requirements. With a good voltage regulator and some capacitors, however, you can probably make most MCs work for you (also well described in the wiki).
Spec sheet for the NRF24L01+
You'll need to install the RF24 Library from this site. The examples with the library which are copyright 2014 by TMRh20 are good.
This forcetronic site has code for a three device network. My code draws very heavily from this example.
Step 1: Hardware, Software and Connections
For this network you'll need:
1. 3 - 7 MC devices (e.g. Arduino, Leonardo, etc.)
2. same number of NRF24L01+ RF devices
3. jumper wires for the connections
4. sufficient USB ports or other power source for above
5. the RF24 library from the fourth link on the prior page installed in the Arduino IDE
6. 0.1 uf capacitors recommended
The connections are laid out in detail in the first link on the prior page. Basically, the pins in the lower right corners of the diagrams above must be connected to the corresponding Arduino pins. VCC must be 3.3V and CE and CSN from the NRF24L01+ connect to pins 7 and 8, respectively, on the Arduino. The IRQ pin is unnecessary in this application. Soldering a 0.1 uf capacitor between the VCC and ground pins of the NRF24L01+ is a good idea.
Step 2: The Meat - May Be Tough and Dry
This diagram is the key to understanding how this network works. I've tried to capture the essence of it in the following paragraphs. The next paragraph is by far the most important, as well as being the easiest to follow :) The following step of the Instructable includes code that will also help clarify how this network works.
The defining multiceiver capability is having up to 6 channels (pipes) of radio communication open in a receiving (RX, or "read") mode simultaneously. This takes the form of a hub receiver (PRX - primary receiver) and up to six transmitter nodes ( PTX1 - PTX6 primary transmitters). To simplify the above diagram, six reading (Data) pipes are opened in the primary receiver hub (PRX). Each PTX node links to one of these pipes to use both in transmitting and receiving (TX toward the hub being the primary direction of data flow, but the PTX nodes are RX capable as well). Note that the hub can also "stop listening" and act as a TX, transmitting (or writing) to the PTX nodes -- but this can only be done one pipe/ node at a time.
The addresses/ pipes must have a distinct pattern of bytes: only the fifth byte is entirely unique among all the pipes and is known as the least significant byte (LSB) . Pipe 0 is assigned all five bytes independently. Pipe 1 is also assigned all five bytes independently, but then the first four bytes ( the MSB) of pipe 1 also become the first four bytes of pipes 2 - 5 (if they exist).
Given the design of the hardware and lower level software (libraries), the TX -> RX sequence follows a simple pattern within a sketch. Data payloads can be of static or dynamic length (bytes) and may also be attached to ACK (acknowledge) packets that are routinely returned from receiver back to transmitter to confirm successful transmission (ACK packets, incidentally, are more efficient than repeatedly switching between transmission and reception for two way communication). User management of network traffic largely boils down to restricting transmissions to levels that don't overwhelm RX capabilities (my very simplistic understanding). Error trapping to account for dropped or corrupt data packets, buffer overruns, etc. may also be needed to ensure data integrity.
Step 3: The Code
This example is a frivolous game in which the PRX generates a random number and the nodes try to guess the number. Its real purpose is to demonstrate the network in action.
The files in this step contain code for the PRX primary receiver (hub) and for the PTX primary transmitters (nodes)
The #define WHICH_NODE statement needs to be altered for each node. Otherwise, the node code is the same.
When running, I suggest powering the PRX first and starting the serial monitor for it. Otherwise you might miss the action!
ENJOY! And please do comment on any way in which this Instructable might be improved.