Simple nrf24L01 with Arduino Sketch and Setup


I have been working with the 2.4Ghz nrf24L01 modules on a few projects. These modules are very inexpensive (about US $1.25 ea. when bought in quantities of 2 or more on eBay), and they seem to work well for short range, small payload data transmittal. This walk-through will show you how to wire them up, and then will demonstrate a pair of very basic sketches (one for the sender, and one for the receiver) used to verify that data is being sent wirelessly.

You will need (hardware):
(2) nrf24L01 2.4ghz wireless transcievers
(2) Arduino Uno (or compatible)
(2) LEDs: Red and Green (or whatever you have)
Recommended: male-female jumpers for connecting nrf24L01 modules to Arduino

You will need (software):
Arduino IDE
RF24 libraries by maniacbug (

The image below shows the view of the nrf24L01 from the top.  Note: the pins are on the bottom-side.  The image shows the top-side.


This drawing shows the basic connections from nrf24L01 to Arduino.  For this sketch, the only difference between the sender and the receiver will be that two LEDs will need to be added on pins 3 and 5 (or whichever you choose, really).

closeup of nrf24l01 to arduino connections
closeup of nrf24l01 to arduino connections
The send and receive Arduino setups.  Pay no attention to the LEDs without resistors.
The send and receive Arduino setups. Pay no attention to the LEDs without resistors.

Once you have the sender and receiver wired up, you will need to upload sketches to each.  All the sender sketch does is send values 0 to 255 to the receiver, repeatedly.

On the receiver side, the sketch just reads the sent data and compares it to the last value received.  If the value received is equal to the last value plus one, the green LED will light.  If it is not, the red LED will light.  This works pretty well to visually display how reliable the signal is.  If you see lots of red, you know you are dropping packets.  Note, though, that this sketch will blink the red LED once each cycle to indicate that a complete 0-255 cycle has taken place.

Again, the idea behind these two simple sketches is to get down to the most basic possible setup for use with nrf24L01.  I hope this helps someone trying out the nrf24L01 transceivers for the first time.  The video embedded below shows the behavior of the receiver when it experiences lost wireless packets.

Sketch for the sender:Sketch for the receiver:


20 thoughts on “Simple nrf24L01 with Arduino Sketch and Setup”

  1. Hey well done, worked a treat and let me test my place to see how well they would work here, Thanks for information. Cheers, Terry.

  2. How do I find the RF24 libraries in my program files? Is it already downloaded, or do I have to define all the #include libraries?

  3. The one problem I encounter was with the Rx code where you have
    done =, 2);
    It wouldn’t compile for me. All I did was take out the “done =” and it worked perfectly. Zero drop outs, places my hand over the rx and tx, no drop outs. Just ran perfectly. I Thank You very much, I am a total noob, no experience with this and I have been having massive issues trying to make these rf modules to work. So happy I found your code to atleast check the modules work. Again Thank You. Very well done.

  4. Hey,
    Thanks for nicely explaining about nrf2401. I am also going to implement this for one project. Before Going to the project I need to be clear if can solve my issue. I have eight substations need to be connected to central base station wirelessly. I am thinking about using NRF2401 wirelesss module. Can multiple items be used on to send/receive data on demand?

  5. Hi, been working on just trying to get two of these transceivers to talk to each other for days. Can’t get them to work at all.
    Tried using an external 3.3V supply for the transceivers, using a capacitor from Vcc to ground for the 3.3 supply, multiple libraries, changing the code, different transceivers, etc. My sending unit seems to be transmitting from what I see in the com window, but my receiving unit just keeps saying that there is no information available. Any ideas?

  6. Thanks a lot. It worked like a charm.
    A small modification for the updated RF24 library.
    Remove the while(!done) loop, and ‘done’ variable itself.
    if (radio.available()){, 2);


  7. Hello, I need to send just a continuous wave with maximum output power. Do you know the command for that ?
    thank you in advance.

  8. I am working on the same code and library but it didn’t worked well. I am facing issue, where in packet loss led is continuously glowing i.e. red and not blinking and data received led(green) is not glowing and not blinking.I am powering both arduino’s on PC USB.Also I am not able to see anything on serial console on baud rate 9600.Please help me to sort out this issue.

  9. Hello there , thank you so much for your efforts .
    I have a question please :

    I want to know the arguments of reading and writing functions ,
    and why did u write:, 2);
    and : radio.write(msg, 1);

    thank you in advance .

  10. Thank you very much for this explanation given to the point! Everything started working from the first try :) and most importantly without any doubt and wondering. Before your site I have digging over the web…

  11. thanks a lot for that ! it works well but i’m at very beginning of that ,have no experience is there anyone who can tell me what do these codes do ?
    radio.openReadingPipe(1,pipe); // what does ‘1’ do there ? for what reason ?, 2); // msg – 2 ? why 2 values into the paranthesis

  12. Hi!, I just discovered your site (after been struggling for weeks to make the modules work) and test your sketches and they are working now!
    Thank you very much for your tutorial.

Leave a Reply to karthikeyan Cancel reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>