Using an NRF24L01(+) with an Arduino
The NRF24L01 is a simple radio. One can use it to send and receive messages of 1...32 bytes in size. This message size is dynamic. It has 6 channels of which one can be used to transmit messages to (pipe 0). That is: you configure pipe 0 with the address you want to send to, pipe 1...5 are the addresses you receive messages on. Note: only the LSB (least significant byte) of pipe 1...5 can be different, the other part of the addresses must be the same. Pipe 0 can be anything.
I found this page really useful for connection details.
getting it to work
I had lots of problems getting it to work. No data was received at all or only for a short time.
What follows is a list of things I find are required(?) to get it to work in my situation (arduinos distributed through my not that big house).
- Greg Copeland's library is the most convenient, flexible and works best.
- do not connect the radio to the 3.3V pin of an Arduino: it can't give enough/stable power, use e.g. an ld1117av33 to downconvert 5V to 3.3V
- connect the radio to an i/o pin of the arduino, that way you can easily power cycle it. in my case I powercycle them every 60 seconds but you could also decide to use an other interval or if e.g. you have not received any messages for some time
- try to find a channel that is not used by anything else. for this you can for example use a WiSpy or any other 2.4GHz wifi frequency analyzer (it uses the same frequency band). note that the wifi channel numbers do not directly map to the ones of the NRF24L01.
- use "setRetries(15, 15)" to set the retry-interval to the longest possible and to use the maximum number of retries
- set the data rate to 250Kb/s (works only with the p-variant)
- use 16b CRC
- if you have an NRF24L01 with a external antenna (not a pcb antenna (the wiggly line at the top)) you can consider connecting a larger antenna to it. I connected regular wifi antennas.
- when toggling from receive to send or the other way around, add a "delay(5)" after the switch
- after transmitting data, add a "delay(5)"