Getting Started with nRF24L01+ on Arduino

RF24 Getting Started - Finished Product

Nordic’s nRF24L01+ 2.4GHz RF radios are a great way to communicate wirelessly between Arduino’s. They’re cheap, and powerful. Unfortunately, they can be a little daunting to beginners to get started. Today, I want to make it easy for total beginners to get up and running on nRF24L01+ radios quickly and easily.

Stuff we need

First, we have to go shopping. A great place to start is the iTeadStudio store. Here’s what you need. Obviously, you’ll want to buy two of the radios and protoboards because what good is a radio that can only talk to itself?

Reasonable substitutes for this stuff can also be found at Sparkfun if you like spending a lot more money. Also the radios are at


We only need one of the 2×4 pin female headers. Cut off two chunks of the male headers, lengths of 6 and 8 pins. Cut wires to about 2inches in length. If you use the 7cm wires from iTeadStudio, it’s OK, you’ll just have a little extra wire in the way.

Here’s what it looks like all ready to go. Click on the picture for a closer view. In this picture, I am using a pair of 4-pin female headers instead of a 2×4 female header. I also cut an extra green wire I decided not to use in this tutorial.

RF24 Getting Started - Parts

Solder it up

  • The 8-pin male header goes in position C09-16.
  • The 6-pin male header goes in position V13-18.
  • The 2×4-pin male header goes in position K16-N15.
  • The wires are connected as follows:
Line From Arduino Pin From Grid Position To Radio Pin To Grid Position
GND GND U17 1 N17
3V3 3V3 U14 2 N14
CE 9 D15 3 M17
CSN 10 D14 4 M14
SCK 13 D11 5 L17
MOSI 11 D13 6 L14
MISO 12 D12 7 K16

Here’s what it looks like with all the wires in place, up close and personal. Again, click through for even bigger images.

RF24 Getting Started - Connections Close-up


Get the RF24 library from github. There is ample documentation at that link, as well as a pointer to the downloads page. Unzip the archive in to your ‘libraries’ folder under your sketch folder (mine is in /home/users/maniacbug/Source/Arduino/libraries), and restart the Arduino IDE.

From the File menu, select “Examples”, then “RF24″, and finally “GettingStarted”. This will load up the GettingStarted example. It looks something like this. Take a look at the GettingStarted example in the documentation for all the details.

 * Example for Getting Started with nRF24L01+ radios. 
 * This is an example of how to use the RF24 class.  Write this sketch to two 
 * different nodes.  Put one of the nodes into 'transmit' mode by connecting 
 * with the serial monitor and sending a 'T'.  The ping node sends the current 
 * time to the pong node, which responds by sending the value back.  The ping 
 * node can then see how long the whole cycle took.
#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
#include "printf.h"
// Hardware configuration
// Set up nRF24L01 radio on SPI bus plus pins 9 & 10 
RF24 radio(9,10);

Upload the sketch, start the serial monitor, set the speed to 57600, and you should see this:

ROLE: Pong back
RX_ADDR_P0-1 = 0xf0f0f0f0d2 0xf0f0f0f0e1
RX_ADDR_P2-5 = 0xc3 0xc4 0xc5 0xc6
TX_ADDR = 0xf0f0f0f0d2
RX_PW_P0-6 = 0x08 0x08 0x00 0x00 0x00 0x00
EN_AA = 0x3f
EN_RXADDR = 0x03
RF_CH = 0x4c
RF_SETUP = 0x07
CONFIG = 0x0f
DYNPD/FEATURE = 0x00 0x00
Data Rate = 1MBPS
Model = nRF24L01
CRC Length = 16 bits
PA Power = PA_HIGH

Instead, if you see a lot of zeroes everywhere, something is wrong with your connections. Double check them all again! In the course of making this tutorial, I even switched two of the wires myself and had to re-solder them. If you hooked everything else up right, you will see numbers just like those above.

Make another one

Ok, do it all again, making another protoboard shield, on top of another Arduino, so our first unit has something to talk to.

Start the second unit up, just like above, and launch the serial monitor at 57600. Press the ‘T’ key once the debugging text has printed successfully. That will put this unit into Transmit mode, which sends a ping out to the other unit. Make sure the other unit is still running, so this one has something to talk to!

Soon you will see the happy chatter of the radios doing their thing:

Now sending 90...ok...Got response 90, round-trip delay: 28
Now sending 1122...ok...Got response 1122, round-trip delay: 26
Now sending 2152...ok...Got response 2152, round-trip delay: 27
Now sending 3182...ok...Got response 3182, round-trip delay: 29
Now sending 4214...ok...Got response 4214, round-trip delay: 27
Now sending 5244...ok...Got response 5244, round-trip delay: 29
Now sending 6277...ok...Got response 6277, round-trip delay: 26
Now sending 7307...ok...Got response 7307, round-trip delay: 26
Now sending 8337...ok...Got response 8337, round-trip delay: 29
Now sending 9369...ok...Got response 9369, round-trip delay: 27
Now sending 10399...ok...Got response 10399, round-trip delay: 29
Now sending 11431...ok...Got response 11431, round-trip delay: 27
Now sending 12462...ok...Got response 12462, round-trip delay: 28

From here…

The examples directory in the RF24 library has all sorts of different things you can try. If you’re feeling adventurous, you can even hook up the IRQ pin from pin 8 on the radio to pin 2 on the Arduino (that was what the extra green wire was for in my ‘parts’ picture).

Instead of the ghetto-style ProtoBoard setup, you could step it up a notch and use a Arduino ProtoShield Kit. See the more recent post, Getting Started with nRF24L01+ using a Protoshield

In a future post, I’ll put up a simple PCB you could use instead of all the soldering. It’ll be a little smaller, too.

About these ads


Filed under Arduino, RF Radio

238 responses to “Getting Started with nRF24L01+ on Arduino

  1. I have purchased the Nordic nRF24L01+ and the Nordic FoB. I am running Arduino 1.0 and first tried Mirf…and then found your libraries (thanks). My question is receiving the calls from the Nordic FoB ( ) instead of two Arduinos as in your instructions. Can you post something on using the FoB – receiving the commands on the RF24L01+ ? Thanks.

  2. Commented in wrong spot – anyway, yeah, my donation for libraries and extension to the FoB controls –

  3. Just let me know where to send it…

  4. Done :-) If you could post with the instructions getting the receiver on a breadboard via an Uno (I’m new to Arduino) – and then talking to the FoB – that would be great. Thanks.

    • Thanks very much! The receiver doesn’t fit onto a breadboard, though. The 2 rows of pins are too narrowly spaced. The tutorial above is really the easiest way to get it working. Alternately, you could just connect wires from the Arduino to the module if you had wires with female ends on one side. In that case, just follow the table above by “Solder it up”. For example, you’d run a wire from Arduino pin 13 to radio pin 5, and all the other lines listed in that table.

  5. Andrew

    hey ManiacBug, I am having problems with the code, I am running the most recent IDE, and I get errors such as these:

    What do I do to fix all this so I can get the wireless node working? Thanks, Andrew.

    • Wow, it looks like you’re having problems in general with SPI. Can you try compiling the SPI library examples first to make sure your system is fully functioning?

  6. Hi, just wanted to thank you for this blog, it’s exactly what I have been looking for. I agree that Nordic is the way to go. I ordered the istore setup and will be attempting to replicate what you’ve done, including the fob thing.

    Thanks again for making it easy, Adrian

  7. You’re welcome, and good luck with your project!

  8. Look like nice work. I’m moving away from the RF22 (433MHz) to the RF24 for this project . . .
    I first ran across the “Mirf” lib. Yours looks a lot more complete. However, I was wondering about RAM & SRAM use. I’m writing to an SD, RTC, etc. The RF22 lib I used would just barely fit.
    Anyway, great job. I’ll know better when I begin to use it.

    • Thanks! Well, if RAM is a concern, RF24 will do you right. An instance of RF24 takes 16 bytes of RAM. The library itself uses none whatsoever. At least it won’t use any shortly when I commit some optimizations I’m working on.

      Are you also worried about flash memory? RF24 uses flash memory with abandon. I can give you some tips to reduce it, if flash memory ends up being a problem.

    • Margaret

      I’m exploring low cost wireless between Arduinos. You noted: “I’m moving away from RF22 (433MHz) to the RF24….”

      Why are you moving away from RF22? Is it lacking in features RF24 provides? Or perhaps a better question. When would you use RF22 and when would you use RF24?

      THANK YOU!

  9. Well, I was right – it *is* a nice lib. I appreciate it.
    I ported my RF22 project to it without a problem. I do have a question though.

    The nRF24L01+ is drawing 6.5mA in powerDown mode. The call is OK as jumps up to over 20mA in powerUp mode. I’m using the $20 Mdfly version with the amps. So I’m wondering if the high current is due to the amps, or the level of power down that the call makes. Any thoughts?

    • Thanks! As to power consumption, the chip itself only consumes 12mA max when receiving, and 900nA in power down. There must be something else on the module consuming power. The power amp seems like a good guess. MDfly doesn’t publish a schematic, so it’s hard to say for sure.

      Personally, I only use the low-power units on battery-operated nodes, reserving the high-power units for nodes connected to wall power.

      • david

        hi, I also experience the same think, i have using this module and switch it in RX mode to power down mode in 0.5second interval, first it’s seems everything ok including current in powerdown is normal, but after many hours under test , the nrf24L01 is damage, (in term of power down draw 6.5mA, but rcv and TX function normally), i was curious what may caused the problem, i have tried to replace the nrf24l01 8 times so far, but still not resolve the problem, all have the similar behavior, they were run perfectly at first , and show the failure after some hours or days under test, all ended with the same problem (tx and RX function normally except in powerdown it’s no longer drawn 900nA ,but around 4.5ma up to 6.5ma )

        since my application have to be very low power, it is become a problem for me , ( sadly i have bough 4000pcs of this module and 1000pcs of the chips), and I dont have any more idea what i have to do, if you guys have and idea what to do pls advice me



      • Interesting findings, thanks for sharing. Sorry to hear you’ve got so many units and now it’s failing! I haven’t tested power draw for nodes that have been in use for days, but perhaps now I should!

  10. Thanks for your help on my previous questions. I have one last issue that is driving me nuts, and was hoping you could help.
    I have a 16 byte struc that I send to the server. It’s received fine.
    Then using “ack with payload” the server sends back a 5 byte struc in the ack. The 5 bytes are a char and a long.
    When the ack is received by the client, the char is received fine, but the long is always just a huge garbage value.

    I’ve tried various changes to the ack structure – adding more fields, 4 byte boundaries, etc. but no joy.
    I also tried dynamic payload, with no help, and figure since the size of the ack struck is constant I don’t need to use it anyway.

    I know it might be hard to answer without the code, but wasn’t sure if I should post it, email it, etc.
    I do have a small sample that demonstrates the problem.
    Any insights you may have on this would be greatly appreciated.

    • There might be limits on the size of an ack payload. Did you check the data sheet? Ack payloads automatically enable dynamic payloads. What size is reported back when you query the size of the payload? Try using getDynamicPayloadSize() to see what it says.

      As to the code, please use github gist, pastebin, or, and post a link here.

  11. Hello, My understanding from the data sheet is that 3x 32byte payloads are available with ack payload transmissions just like “regular” kind.
    I added getDynamicPayloadSize() on the client side and it reports 5 bytes which is correct.
    I zipped both examples and they can be downloaded at . . .

    I have a feeling I might be making a bonehead mistake, but I don’t know what it is!
    Thanks for your help!

    • This part doesn’t look good…

          bool done = false;
          while (!done){             // THIS WHILE WAS JUST ADDED IN CASE IT WAS NEEDED
            done =,sizeof(rcve));

      You are doing another ‘read’ into the same memory area as the first, thereby throwing away the results of the first ‘read’. Shouldn’t be calling ‘read’ the second time.

      But this part looks bad too

        bool ok = radio.write( &xmit, sizeof(xmit) ); // send - blocking
        if (ok) Serial.println("OK ");
        else Serial.println("Failed");
        // FOR ACK PAYLOAD
        radio.startListening();  // NEEDED - BUT NOT IN EXAMPLE
        if (radio.isAckPayloadAvailable())    {

      Once you startListening(), you can’t expect to get ack packets. Ack packets are for senders only. A TX-only unit should never start listening.

  12. Thanks for your reply.
    Regarding the “while (!done)” I had just tried that in desperation. I assume it’s used when >1 payloads are sent. Sorry, I should have removed it. (Doesn’t make a difference one way or the other though. )

    “Once you startListening(), you can’t expect to get ack packets. . . ”

    I can understand that. It isn’t in your pingpair_pl example (hence the comment). But as strange as this might sound, If I remove that line, I will only transmit once, and will never receive an ack. In short, I *do* get ack packets after calling startListening(), and I don’t if I don’t call it.

    With the startListening() call in, the sender (my “client” example) will send, and will receive an ack from the server. However, the only problem is that the 2nd field in the struc is not right. The first field in the ack (a char) is always fine.

    If you run the examples with the serial monitor on the “client ex” you will see this behavior. (There is no need to put an LCD on the “server” example. )

    Thanks again,

    • It’s more likely to solve your problem to figure out how to get things to work right without the extra call to start/stopListening(). They aren’t the solution, they are a workaround that is sort of getting it to work but obviously not getting it to work right. If the client can only transmit once, something is clearly wrong. The pingpair_pl example transmits more than once, right? My suggestion is to rebuild the sketches, starting with the working example as a basis. Test as you add each layer and then you’ll know the moment you added the non-working part.

  13. I went back to the unmodified pingpair_pl example.

    Note that for the sender side, this example will always print “OK” – even if there was no ACK.
    (it’s outside “if ( radio.isAckPayloadAvailable() ){“)

    Even using that example, I could not get transmissions back and forth without adding . . .
    “radio.startListening();” just before the “if ( radio.isAckPayloadAvailable()” on the sending side.

    Everything is wired correctly, I’m using “” and R0022 of the IDE.
    (Should I try IDE 1.0 ?)

    At a minimum, you should change that example so “OK” is printed only if there is an ACK.
    At this point, I have to question why a “startListening” isn’t needed before a “isAckPayloadAvailable”.

    I will continue testing the example with send and ack structures. However, I suspect the “workaround” that I had to do is unrelated to that problem.

  14. uzma

    i would like to know the program and the method on how to connect the sensors with rf transceiver and can get the output on the laptop.
    actually i want to make a wireless robot and i am using a 2.4ghz rf transceievr and i am a bit confuse that how to write program for sending the sensor output to the transmitter.

    • To connect to a laptop using the materials described here, you would have a radio attached to an Arduino attached to your laptop. You’d interact with the Arduino using the Serial Monitor, and (possibly) send commands to your robot which also had a radio and an Arduino.

  15. uzma

    thank you for the reply. still a bit confuse.i have these components
    arduino uno- 2 qty
    vrbot- 1 qty
    ultrasonic sensor-1 qty
    rf 2.4 ghz transceiver- 2
    now i will explain my project to u.
    actually i am making a voice controlled robot. and i thought of using 2 arduino uno, one for the transmitting the voice from laptop using microphone and other for the receiving, and i am also adding a distance ranging sensor at the second arduino( which is receiving voice), for that i am using a 2.4ghz transceiver. now the confusion is the above program will work on 2.4ghz transceievr?
    2.for sensors do we have to write simple ping program or we have to modify the program? we can easily get the output on our laptop from the second arduino using rf?

  16. uzma

    can i use tr24a with the arduino using above program.i am attaching its datasheet and i want to use arduino with it…will it work:(

  17. Keith Douglas

    Awesome, easy to use library for the nRF24!

    I have a feature request, not a problem…

    As part of my system, I’m using Nike+ sensors (nice off the shelf-package). But they require 3-byte addresses. I hacked the library to allow this, but it would be great if the library supported different address-widths directly.

    (Works great with the Nike+, BTW — channel 25, payload 27 bytes, 16-bit CRC, 250kbps, Rx Addr 0xC2BD0D ).

    • Wow that’s super cool! Can you share what you’ve learned about the protocol that’s used?

      So you transmit from the nike+ and listen with rf24 module?

      Is there a cheaper unit than $200??

      • Keith Douglas

        I’m using the Nike+ as an active RFID. The Nike+ powers up and transmits whenever it detects that it is moving.

        Byte 0: seems to be a packet type
        Byte 1-4: ID
        Byte 5+: I don’t use the rest for my application.

        Others have done a much better job digging into the details of the packet:
        (Note that what you receive with the nRF24 is somewhat different than what you receive with the Sparkfun Nike+iPod Serial to USB adapter)

        You can buy a stand-alone nike+ sensor for ~US$19. The sparkfun keyfob is $25. I had planned on reprogramming the keyfob to transmit a beacon every second, and sleep in between, but the nike sensor seems to be working pretty well. The only issue is that sometimes you need to give a pretty big motion to get it to power-up.

        Next up: Getting the nRF24 to listen for both a KeyFob and a Nike+.

    • Hi Keith – could you give me a few more pointers on the use of the nRF24, Arduino and Nike+ please? I’m trying to use the Mirf library, but so far without success.
      Any chance you could share your code?
      Thanks a lot,

      • Keith Douglas

        Sorry I didn’t get back to you sooner. Here’s some code snippets:

        In the RF24.cpp file (part of the library), in the RF24::begin function, add this line right before "setPALevel( RF24_PA_MAX ) ;", add:

        write_register(SETUP_AW, 1);

        (this allows 3-byte addresses rather than 5).

        Hope this helps.

        By the way, I've abandoned using the Nike+. It doesn't always get enabled by small motions. Instead, I'm using a Nordic KeyFob from Sparkfun which I've modified to transmit a beacon once every second.

  18. uzma

    thanks for your suggestion.. so should i go for the nrf24l01…
    it will work on both process???? for sending the signal to second arduino and receiving the signal from the same??

  19. uzma

    its obvious we can send the voice commnd through the first rf to second but confused weather we can receive the signal from the second to the first????

  20. Oehoeboeroe

    Great work! Finally I have got my devices from ebay seller. Some soldering and up we go. All in 1 night..amazing stuff!
    Keep up the good work, Thanks!

  21. uzma

    i am confuse wheather to use rf or xbe….

  22. Gary B


    Excellent library as many others have said on here, and all the examples I have tried, have all worked.

    Not sure which way to go as you have two libraries RF24 and RF24Network.

    I will be controlling my house heating, requiring the following:
    Send Room temperature data from Arduino to nRF24L01, then to another nRF24L01 on the PC. (When a change occurs)
    Send Hot Water temperature data from Arduino to nRF24L01, then to another nRF24L01 on the PC. (When a change occurs)
    Send Outside Air temperature data from Arduino to nRF24L01, then to another nRF24L01 on the PC. (When a change occurs)
    The data will be in a format something like “Sensor001,+18″
    The data will be in a format something like “Sensor002,-08″


    I will be controlling my Boiler, Turn On or OFF requiring the following:
    Send data “Boiler On” or “Boiler Off “from PC to Arduino to nRF24L01, then to another nRF24L01 to a Arduino that turns on a Relay, to turn on the boiler.

    Can you advise me which of your libraries would be best suited regarding the above ? and any tips you could give me would be greatly appreciated



    • Thanks! Sounds like a cool project, I hope you write it up and post a link when you’re done.

      RF24Network sits on top of RF24, providing some extra functionality. For the scenarios you described, RF24Network would likely make things simpler and easier, so I would start with that. RF24Network is only used by a small set of people, and I really haven’t announced it publicly, so it’s less mature. Please be sure to report any issues you find.

  23. uzma

    will this help to work on wireless connection with ping…i think it will work just need ur valuable suggestion

  24. hollywood

    Hey, this is great stuff! I am working on a project using this setup to control a self-balancing remote control robot. I was testing out your gettingstarted code and for some reason it fails to send the packets. The 250 ms delay seems to be more that enough time to send the data. Is there anything you can think of that is causing it to not send? Thanks

  25. Claudio

    Hello and Thank you very much!

    I’ve had a couple of these radios for a while but only now after purchasing my second arduino board I’ve decided to touch them and your library is looking really good. I had a little trouble setting the modules on the Arduino MEGA board, and you probably already know this, but on the MEGA boards the SPI pins are different:
    MISO -> 50
    MOSI -> 51
    SCK -> 52
    SS -> 53 ——> This one also needs to be changed in the constructor (replacing pin 10)

    I couldn’t find this in the RF24 github (altough I did not look very hard), it would be great if it’s there, if not people can find it here!

    Thanks again!

    • Thanks for writing. What needs to change in the constructor? I don’t see any pin-10-specific stuff on RF24 at all.

      • Claudio

        Sorry I meant change in the example, I had to change this line on the “getting started” example to get things going:
        RF24 radio(9,10); —> RF24 radio(9,53);

      • Oh, you should be able to use any pins you like for CSN and CE. It’s not required to use the SS pin (10 on Uno, 53 on Mega). Even radio(9,10) should work on Mega as long as you hook the right lines up to pins 9 & 10.

  26. uzma

    its given that we have to use 10k or 15 k resistor to reduce the 5v voltage…as it will destroy it….so cant we use 3.3v from arduino uno. i am using

    again its necessary to mention thank you for the guidance.

    • That unit has a built-in regulator, so you can use 5V for the supply no problem. Also, the inputs are 5V tolerant. So, no 10k/15k divider circuit needed.


  27. uzma

    i connected the above radio on breadboard and uploaded the above program but its showing an error

    sketch_mar02a.cpp:2:22: error: nRF24L01.h: No such file or directory
    sketch_mar02a.cpp:3:18: error: RF24.h: No such file or directory
    sketch_mar02a.cpp:4:20: error: printf.h: No such file or directory
    sketch_mar02a:11: error: ‘RF24′ does not name a type

  28. uzma

    i have give 3.3v power supply to it and got above error. “the getting started” example should be uploaded on both rf.???

  29. sehinton

    I just connected two RF modules together with two Arduino Unos and uploaded your RF24 library’s GettingStarted to each one, both give the successful serial message to the computer. I tell one to transmit (send a “T”), but it fails. Are both Arduinos supposed to be connected to the same computer? Both Arduinos are connected to USBs of separate laptops. Or does one of the Tx or Rx modules need a different pinout to set the role? mentions something about a role_pin.
    I’m not sure what’s wrong. It’s probably some silly little error. The two modules are about five inches away…could that be too close? I’m going to try some different libraries, my teammate found another library on the Arduino playground, I’ll let you know how that goes. Thanks.

    • For the Getting Started sketch, no different pinouts are needed. Definitely don’t need to be connected to the same computer. You could try moving the units further apart. Also double-check all your wiring.

      • sehinton

        You were right, I had two wires swapped and I wasn’t paying close attention to the Serial message to see that all the values were zeroes. Problem solved, thanks for the great library! I’m going to modify it to send characters and messages between Arduinos now and eventually to transmit the controller protocols of the vintage systems–NES, Sega, etc.

      • Awesome, glad to hear it. Good luck in your project!

  30. sehinton

    Hi again, now I’m playing with the led_remote, I’m wondering if there is a typo…
    line 172, should it be led_pins[i] instead of button_pins[i] ?

  31. uzma

    i am working with nrf…given the connection as above but in serial monitor it showing the below…
    i have checked my wires many times..
    is everything correct..coz i am not getting everything zero but below values

  32. uzma

    THANK U…

  33. I’ve been trying to sent 2 analog values from one Arduino to the other using your library but can’t get it to work. The example sketches work so it’s my lack of programming knowledge that is the problem. Could you be so kind to have a look at this ->,97026.0.html

  34. Gary

    I wish to send out a ‘float’ variable, using the RF24 network. The variable is named ‘actual_temperature’

    In your code below what changes have to be made to enable this to work ?

    Thanks in anticipation


    last_sent = now;

    const char* hello = “Hello, world!”;
    RF24NetworkHeader header(/*to node*/ other_node);
    bool ok = network.write(header,hello,strlen(hello));
    if (ok)

    • remove the “const char* hello” line, and change all other references of ‘hello’ to ‘actual_temperature’. change strlen to sizeof. do so on the rx and tx nodes.

      • Gary


        Thanks for the quick response.
        I have tried what you said to do but am getting error messages (see below for changes to code and errors).

        last_sent = now;

        Serial.println(” “);
        Serial.print(“Sending… the data = “);

        RF24NetworkHeader header(/*to node*/ other_node);
        bool ok = network.write(header,actual_temperature,sizeof(actual_temperature));

        if (ok)

        Gives me the following errors in the Arduino IDE

        Setup.cpp: In function ‘void RF()’:
        RF:19: error: no matching function for call to ‘RF24Network::write(RF24NetworkHeader&, float&, unsigned int)’
        Y:\arduino-1.0\libraries\RF24Network/RF24Network.h:148: note: candidates are: bool RF24Network::write(RF24NetworkHeader&, const void*, size_t)
        Y:\arduino-1.0\libraries\RF24Network/RF24Network.h:153: note: bool RF24Network::write(uint16_t)

        Hopefully this helps?

        regards Gary

      • Gary

        Still having problems, I hope you can help, I have changed the code as you asked for the TX code to the following:

        network.update(); // Pump the network regularly
        unsigned long now = millis(); // If it’s time to send a message, send it!
        if ( now – last_sent > interval )
        last_sent = now;

        tempC = 11.96; // Set to 21.96 for testing this code only !

        Serial.println(” “);
        Serial.print(“Sending… the data = “);

        RF24NetworkHeader header(/*to node*/ other_node);
        bool ok = network.write(header, & tempC, sizeof (tempC)); // NOTE ….. the ‘&’ was added as it would not compile without it ?

        Serial.print(tempC); // This prints out correctly

        if (ok)
        Serial.println(” ok.”);
        Serial.println(” failed.”);

        I have left the code on the RX as you made it. As I think its correct ?

        network.update(); // Pump the network regularly

        while ( network.available() ) // Is there anything ready for us?
        RF24NetworkHeader header; // If so, grab it and print it out
        static char message[32];,message,sizeof(message));
        Serial.print(“Received: “);

        When i run the TX code I get the following on the RX :
        Received: ®¯A = actually I sent 21.96

        and for another test I also sent the following:
        Received: )\?A = actually I sent 11.96

        It may be because tempC is a ‘float’ and somehow not being sent correctly ?
        Any ideas would be greatfully appreciated as I have spent many hours trying to find what is wrong ?

        Thank you

        Regards Gary

  35. Gary


    I have solved the errors (I looked at your sensornet example) and there was a ‘&’ missing. The corrected line is below.

    bool ok = network.write(header,&actual_temperature,sizeof(actual_temperature));

    Is the ‘&’ used as a (bitwise and) or a (pointer) ?

    Regards Gary

  36. Mats Ekberg

    great lib that I am using to collect metrics in my house, such as energi consumption and temperatures.
    I do have some questions on the payload size. Somwhere I read the the sending and receiving device must have the same payload size. That seems reasonable. But if the transmission between the two devices is swapped, can the payload size be different from the previous transmission?
    And how doeas static and dynamic payload size work?

    Any clarifications would be very helpful.

    Mats Ekberg

  37. Gary

    Hi, somehow my posts have got transposed on your web page. My latest one should be the one dated March 19,2012 at 1:19pm.

    Hopefully you can help with the problem I describe.

    Thanks for all your help

    Regards Gary

    • Now the problem is you are sending a float but expecting to receive a string. You have to change the receiver to pull a float out of the message, not a string.

  38. Gary

    Thanks for that info, still being fairly new to Arduino how would I, pull a float out of the message?
    I would think its in this code, what do I need to add or takeaway ?

    Once again thanks .

    regards Gary

    while ( network.available() ) // Is there anything ready for us?
    RF24NetworkHeader header; // If so, grab it and print it out
    static char message[32];,message,sizeof(message));
    Serial.print(“Received: “);

    • Just like with the receive unit, make the same changes to the transmit unit. Change ‘message’ to your float value, and use the & operator. Anyway, the Arduino forums are a better place to ask general questions on how to use the language.


  39. Gary


    Not sure if this is a bug?

    I am using two Arduino’s with a nRF24L01+ module connected to each.
    I am using the provided examples in RF24Network which are helloworld_rx and helloworld_tx.

    The modules are set a long-distance apart and are working correctly although at the boundaries of communicating. When a person walks between their paths. they lose contact with each other. Which I would expect in this case and is normal.

    What I think I may be a bug?
    Is when they re-establish communications, sometimes I receive multiple messages on the RX Arduino.

    Sometimes it is normal and I get one message but sometimes two, three or even four all at the same time That scroll down the page?
    I would have expected one message and the next two seconds later as normal.

    If you wish to recreate this problem I set the following to make the testing easier:

    Hopefully the above helps you, if indeed it is a bug?

    Thank you very much to help

    Regards Gary

  40. Gary


    Just downloaded your new RF24Network / examples / helloworld_tx / helloworld_tx.pde and RF24Network / examples / helloworld_tx / helloworld_rx.pde that you uplaoded today on Mar 25, 2012.

    And reference to my above comments ‘Gary March 24, 2012 at 8:21 am’

    I obtained the following results when the radio modules were just working and then stepped in front of them. Simulating a real life situation. You will notice there are multi reads at the exact same time on some of the readouts, should this only be one read at a time ? The reason I am asking is that my data is sent to a databse and this crashes when multi reads happen, as it was not expecting so much data.

    Thanks for your help

    regards Gary

    Received packet #51 at 104000
    Received packet #52 at 106000
    Received packet #53 at 108000
    Received packet #54 at 110000
    Received packet #55 at 112000
    Received packet #57 at 116000
    Received packet #58 at 118000
    Received packet #60 at 122000
    Received packet #61 at 124000
    Received packet #63 at 128000
    Received packet #64 at 130000
    Received packet #64 at 130000
    Received packet #67 at 136000
    Received packet #68 at 138000
    Received packet #68 at 138000
    Received packet #69 at 140000
    Received packet #70 at 142000
    Received packet #70 at 142000
    Received packet #70 at 142000
    Received packet #70 at 142000
    Received packet #70 at 142000
    Received packet #72 at 146000
    Received packet #73 at 148000
    Received packet #73 at 148000
    Received packet #74 at 150000
    Received packet #75 at 152000
    Received packet #76 at 154000
    Received packet #77 at 156000
    Received packet #78 at 158000
    Received packet #79 at 160000
    Received packet #80 at 162000
    Received packet #83 at 168000
    Received packet #84 at 170000
    Received packet #84 at 170000
    Received packet #84 at 170000
    Received packet #86 at 174000
    Received packet #86 at 174000
    Received packet #87 at 176000
    Received packet #87 at 176000
    Received packet #88 at 178000
    Received packet #88 at 178000
    Received packet #88 at 178000
    Received packet #89 at 180000
    Received packet #89 at 180000
    Received packet #90 at 182000
    Received packet #91 at 184000
    Received packet #91 at 184000
    Received packet #91 at 184000
    Received packet #92 at 186000
    Received packet #92 at 186000
    Received packet #92 at 186000
    Received packet #92 at 186000

    • Yes, as I mentioned previously, this is expected behaviour. The TX node did not receive an ACK from the RX node, so it attempts to resend. Your RX node or your databasewill have to deal with this. For example, you could remember the last packet# sent to the DB, and only send a new packet if the packet# is higher than previously sent.


  41. Gary


    Thanks for that info, al least I know its not a bug and can think of how to solve my issue.

    Regards Gary

  42. Gary


    Just a quick thought, when i receive for example 3 multi reads on the RX side, which one is the valid one that got the ‘ack’.
    I would think it would be in this example the 3rd one, am I correct in my thinking ? So I should then discard the first two as these did not get a ‘ack’ signal.

    Regards Gary

  43. I am trying this example and I am getting this as a readout (sometimes – other times if I wiggle the pins the readout changes completely)

    And then I have another module that gives me the correct numbers nearly every time (the same exact ones you have in your blog post). Obviously I cannot get any communication between the two – I am about ready to give up on this… the modules are incredibly finicky and I can’t even get them to communicate (every example on every website says this is really easy). However, the other options are all too expensive for me at the moment, which is why I want to get this to work – any suggestions?

    • This is a connection problem. The signals are not making it from the module to the Arduino and back. Check your wires. It’s possible. but unlikely, that you have a flaky module as well.

      • Okay, I will check my wiring a few more times – I have also ordered the module from another supplier, hopefully it will be here for me to test today. Do you suggest I solder directly to the nrf24 module? Right now I am using servo leads to connect. Oh, and I forgot about pastebin. sorry about that!

  44. Gary

    Hi Ivan,

    Looking at your data output on pastebin

    You have on one module:
    Data Rate = 1MBPS
    CRC Length = 16 bits

    On the other module:
    Data Rate = 2MBPS
    CRC Length = 8 bits

    They will not communicate to each other unless they are the same. Also each nRF24L01 will retain this data even when switched on and off. You need to resend the correct data.


    Hope this helps


    • That is the same module! I just wiggled the servo leads and the numbers changed! That is why I am going to solder permanent leads to the modules, and have ordered a new one, as my working module doesn’t exhibit the behavior I posted in my pastebin, it gives the same output that you posted in the tutorial. Just a random question – how much range are you getting from these modules? My application is handheld controller for a brushless mountainboard so I need a good, solid connection for about 2-6 feet. Is this reasonable?After I get these to talk to eachotehr, my next goal will be programming a failsafe for loss of radio contact.

  45. Gary

    Hi Ivan,

    You should easily get 20 to 30 ft line of site.

    • Thanks for the help/tutorial – I got the new module today (ordered two just in case) and I now have a working link! Your range figures are encouraging. Next steps – transmit useful data like throttle and killswitch statuses. Thanks once again, this just made my day :D

      • So a quick question – I have one module sending a throttle value to the other module. Then the other sends the value back as confirmation. How would I go about having the reply include 3 more values (in my case, they would be integers representing rpm, temp, voltage)?

      • Have a look at the led_remote example, that sends an entire structure of data.


  46. Hi Ivan

    Thats OK

    I am not the person who wrote the library, thats Maniacbug, I am just someone that is following this project and help if I can.

    The person you should thank is Maniacbug as he’s done all the work!



  47. John Ellinas

    Dear maniacbug,

    In the getting started setup, I get a lot of failures (eg. Now sending 159752…failed. Failed, response timed out.). Is there any reason for this or is there any action to correct it?

    Best regards


  48. John Ellinas

    Although the Rx seems to respond to every cal, I expected all the Tx sendings to be …ok… without a fail indication.

    • Wireless is going to fail from time to time. It’s the nature of communicating over the air. Applications should be designed with this in mind. You can tweak your power settings or try a different channel to see if there is perhaps some interference on the channel you’re using.


  49. Hi Maniacbug
    I need your help to just pass parameter user input at transmit arduino and send it to receiver arduino. Number from one to nine. The receiver glow Led on Pin 13 as many times as requested and finally stops blinking and echo message to sender that I have completed process. In between each glow it echo status to transmitter serial terminal and inform the decremented variable value. If you code this example completely – a very easy and nice approach for beginners like me. Thank a lot for your consideration. This would be a better help for our students here in Pakistan also.

    • Hi there. This sounds like a great project that will help you learn how to work with Arduino. Everything you need is already in various examples you’ve got just to put it all together.

  50. Hi
    Thanks for reply.
    Seen all the examples and studied in detail and evaluate them step by step.
    Both Radios communicated well. Initialised, Ping and reply is OK. A confirm sign all electronics is perfectly working now.
    Using Led_Remote is not understood at first.
    Upload same sketch in both units. then observe the Serial monitor. Roles are done on one by shorting Pin A4 to ground [Analog Pin 4], that unit unit become LED Receiver and displayed role perfectly well.
    Connected one LED on Receiver Pin 2 and started the working.
    Amazed that always Pin 2 and all other pins are glowing. Even no pressed switch on remote.
    Unplug the sender – still don’t know why they are glow after reset.

    Please help in this. Why the LED glows.

    • Also above reply on Serial terminal that sending failed message.

    • > Amazed that always Pin 2 and all other pins are glowing. Even no pressed switch on remote. > Unplug the sender – still don’t know why they are glow after reset.

      This is in the code, led_remote, Line 172: led_states[i] = HIGH; digitalWrite(led_pins[i],led_states[i]);

      setup() sets the LED’s to HIGH on startup. There is even a comment!! “// Turn LED’s ON until we start getting keys”


  51. Hi Maniac
    1. Why remote unit always say sending failed. What this signifies ? The if routine always detect this to execute ? why ?
    2. If look the code and as you say above – setup() sets the LED’s to HIGH mean they are all high as asked in the the setup() initialisation to do so. Then what is the question to why not glow them on start.
    The code execute perfectly well – as what it is asked to do is completely performing well.
    3. A small bit needs to be solved what in between you and me is a very little understood point which might be missing.

    What understood is well.
    Now I only need to pass one variable from remote to other unit and to get its response on other unit.
    Can you help me passing just one variable from one to another.

    Passing parameter is if understood – I can make the LED 13 glow number of times on remote and passing from local Serial Input. or if you can start coding and help me.


    Kaludi Athar – Pakistan
    University of Karachi
    Physics Department

  52. Hi
    Maniac – please explain briefly about the schematic to test Remote LED.
    I seen this – Is this need to be achieved from the PDE.?

    Kaludi Athar

    • Christian Lerche

      To connect LEDs to the Arduino, attach anode with resistor at the pins you’d test. Connect the cathode to gnd.
      Connect a wire from the role_pin (A4) to gnd.

      on the transmitter board connect a switch between the input corresponding to the LED you want to turn on and off,
      to gnd.

      It couldn’t be simpler.

      Now if it works for you, I think something is wrong with my hardware.


  53. Hi Maniac

    Please reply me on the above post – I am waiting for your reply.


  54. g0re

    Dear Maniacbug,
    I have some issues to manage comunication between two NRF24L01+ radios, probably caused by the fact, that the second used device is stadalone ATMega168 with just few necessary components (right this way: + added 3.3V regulator). Do You have any experience with using this radios without arduino boards? My other projects works well on standalone ATMegas and I am using arduino just to burn up and program new chips.
    I tried four NRF24L01+ (one of them was dead, returning loads of fffffs, others shows the same informations as above) and checked wires thousand times. I also switched to MIRF library with same result. I even added some LEDs to lid when listening, receiving and sending data, but even that it works great with arduino, on standalone device LEDs just seems to flash once a while randomly.. :( Is there anything i have to add, like reset switch, rx/tx deadloop or something? I am quite desperate :(
    Thanks in advance for any reply, regards g0re

  55. Christian Lerche

    Hello Maniac
    Nice work you’ve done, I’m impressed.
    Now for the more serious:
    I have two ATMEGA328 boards, and two nRF24L01+ (Pa + LNA) modules.
    I’m using your led_remote example, the receiver works, but the transmitter has troubles.
    Whenever I reset the board, I have to press a button to transmit within a sec or two, otherwise I won’t send it.
    If I wait more than 2 secs, it refuses to transmit the bytes.
    Even if I the first buttonpress transmits I can’t do it again, unless i reset the board and press within 2 sec.
    The funny thing is that the reset doesn’t apply for the modules, only the Arduino is reset.

    Btw, it’s a custom board, but I’ve quadruple checked the wiring for the modules.
    If you need details, I’ll upload at pastebin.
    Thanks in advance.


    • Christian Lerche

      Here some output. I have worked with these in days now, really cant figure out where to look next.


      • Christian Lerche

        I’ve been looking through some of the debugging messages now.
        It looks like the address’ of the modules doesn’t point the right way.
        I’ll try to figure out why this happens.


      • The output looks like the radios are configured fine. Have you tried a simpler sketch, like the pingpair sketch?

        Also, try adding some debugging text to print something out when you send a message so you can verify that your sketch is in fact trying to send a message over the radio.

  56. Paulo Jericoh

    Hi “helpers”, I would like to get your help when I start step-by-step the “GettingStarted” above.
    See bellow, that the first sending is received and sent it back. But the transmitter did not received the senting back… After that, nothing different happened.
    It happens only in the first time. I need to close the ports, reset both arduinos and start them again to reproduce the first ACK.
    I first bought two RF24 modules from eBay. I decided to buy other 3 ones from another seller from eBay. All the 5 modules run the same way and the comunication was not stablished.
    I checked all the connections; step-by-step; got myself tired; I tried in other days, but nothing changed.
    Is there a way to debbug what is happening in order to see what I am doing wrong or the 5 units from the different sellers may be damaged ?
    The Transmitter is an Arduino Uno Rev3 and Receiver, another one Rev.0. I tried both connected to USB’s and also to different power supply.
    I did not build your hardware. I just used male and female wire jumpers to connect the 3.3V, GND and other pins.
    Please, could help me to know what is going on ?

    • Paulo Jericoh

      Any idea, please ?
      Anything ! It is not comom 5 modules from different sellers have the same problem !

      • Paulo Jericoh

        I turned off my 2 WiFi routers and my wireless phone that were near the nRF24L01 modules over the same desk.
        Then I started the “scanner example” ( to see whether there was any interference. I could see that the zeros were changed to 1 or 2 or 3 or 4 in specific ranges (8×16 blocks of channels). The more interesting was that each WiFi Router changed the zeros from different ranges (some intersection).
        I also tested with my cell phone Bluetooth. As the WiFi routers, it changed the zeros from other ranges.
        Without letting my wife to see, I tested her microwave turned on. As the WiFi routers and the Bluetooth, it changed other different ranges, even with channels intersection.
        After the above tests, I changed all the five RF24 modules and the arduino board. The only different result I got was when I changed the arduino. The first one above was an UNO Rev.1. The other was an UNO Rev3.
        When I used the UNO Rev3, no interference took place. I changed the cables and the modules again. There was interference with UNO Rev1, but none with UNO Rev3, with all five RF24 modules. I was not able to explain why ! May be there are some filters on UNO Rev3.
        I tried to change the channel too for the one that there was no interference in those tests (radio.setChannel(3)). But even with the WiFi routers, Bluetooth and microwave turned OFF, the RF24 modules have not communicated.
        When UNO Rev1 is the transmitter, it displays “Now sending 78871…ok…Failed, response timed out.”.
        When UNO Rev3 is the transmitter, it displays “Now sending 8588…failed.Failed, response timed out.”.
        When they are the receiver, both display nothing.
        I made progress. The RF24 modules worked alone but they had not communicated one with each other yet.
        I still need more help. Please… !

      • Valente

        I think that others have had the same problem, specially when using an Arduino MEGA 2560.
        The probably solution is on:

        You have to put a capacitor (100~400nF is sufficient) between the VCC(3,3V) and GND , because on the MEGA2560 we have lot of disturbance (or electrical noise) because the number of ports and peripherals. Also, when we talk about 2.4GHz (the frequency of the NRF24L01+) it’s a little reasonable that a simple ‘cm’ becomes an antenna and then, because its radiation emmited, add some disturbance.

        Finally, this is a good and simple solution.

      • Awesome!! Thanks for sharing! Many people have asked about this problem.

  57. Harry Mallon

    I have two of these recievers. One of them has to run from a 5V arduino mini pro which has no 3.3V output. How should I wire the power for the module (it needs a 3.3V input)? Also I’m very new to this. So be gentle. Harry

    • Harry Mallon

      Also this will be running from a battery so wasted power is an issue. If i have a steady 5V supply could I use a potential divider with two resistors to make 3.3V or would that have hidden problems, power loss etc?

      • I usually use a regulator in this case, like MCP 1700-3300. A divider ought to work, though I’ve never tested it. Seems like it would consumer power. Ask on the “General Electronics” section of the Arduino forum, and you’ll get good advices from the electronics experts.

  58. Christian Lerche

    Found a solution to my troubles. Move the nRF24L01+ modules away from any WiFi source, or at least scan the channels first…
    Nice work Maniacbug. :-)

    • Christian Lerche

      And: Remember to resolder the connections for the antenna on the board. This pesky little SMA was not soldered on to the board at the fourth connection. This meant troubles whenever I didn’t place my have around the antenna, which means a capacity was added to the equation.
      After resoldering the connector, all signals transfers perfectly.
      The only thing that still troubles me, is that the led_board example, actually doesn’t work.
      I’ve made some changes to the Gettingstarted example, and from there, I can light up my LED.
      I think (really, I have actually no idea if this is correct), that the addressing of the modules, somehow gets screwed, when setting the led_board example up.
      I’ll try to investigate, to see if I can make it work somehow.

      Still: Thanks for a great library.


  59. Joonas Kortelainen


    I took on the challenge to try this rf module out, and I’ve come to a struggle.. I’m using ‘Arduino Nano, and well, it doesn’t have a arduino pin 13, so I cant put the SCK anywhere..

    Do I need to edit the library, or how is it done to be usable for the nano?

    Thanks in advance!

  60. Awesome! I have the example programs up and running. I’m now trying to understand better how they work. Can you point me to where I can learn what a line like this from the getting started example is actually doing?
    printf(“ROLE: %s\n\r”,role_friendly_name[role]);
    I know it is somehow sending the role of the device to the serial monitor, but I don’t understand what it’s doing enough to make it do something else if I wanted to. Any suggestions on where I should be reading?

  61. I can’t seem to get two Arduinos to talk to each other following your outline. Does the code need to be changed? I see that there is a section of code commented out for the ping_out. I am trying to talk between a Mega 2560 and an Uno. Is that the problem? they do different things when I test them individually. The Mega 2560 is always sending and receiving a Payload> thanks.

    • Sorry, there is not enough information in your comment to understand what’s amiss. You can try the Arduino forums for some different points of view.

      • Paulo Jericoh

        After a lot of attempts and much headache, I gave it up.
        I decided to work with separated transmitter and receiver. I choosed one 433,92 Mhz pair and they communicated just…FINE… at the first time !
        I made stretch tests and they worked for days communicating without lost of data safely and stable and no “2.4″ interference, of course.
        Besides, one pair of those devices has the same price of this “nRF24L01+” transceiver.
        Until now, the main problem is to address different nodes. I found a library without addressing them. So I am coding my own addressing system, like appending address data to the payload.
        So… go ahead !
        Thank you, anyway.

  62. Mark Hecht

    I just wanted to let you know that I tried out your GettingStarted example and it worked great!

    I had some problems at first that might prove helpful to others:

    Problem #1: Garbage displayed at sketch startup
    Solution: Set the serial monitor baud rate to 57600 like the instructions tell you to ;-)

    Problem #2: I could not get 2 Serial Monitors running at the same time on my Linux PC
    Solution: Start up 2 separate instances of the Arduino IDE (Not just 2 windows from the same instance)

    One other suggestion: I wanted to hook the transceiver modules up to a breadboard, but I didn’t have any headers or f/f jumpers handy. I did have some old PC hard drive cables though, and they worked very nicely.

    Regards and Thanks!

  63. Oleg

    Has anyone tried to improve antenna for this module?

    • Christian Lerche

      I wouldn’t say improve antenna for my modules, but…
      I soldered the antenna connector correctly (Meaning all 4 GND points), so the antenna
      didn’t “see” capacity in the connector. This helped A LOT!
      Now it communicates just fine.


  64. bakla89

    I tried for a long time to get the example working but I couldn’t. I see a lot of zeroes everywhere. I’m really sure I didn’t any mistake with the wires.
    The fact is that I’m using an arduino leonardo + ethernet shield.

    So I changed the “print preamble” in this way (because otherwise the serial monitor didn’t initialize correctly):
    while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
    printf(“ROLE: %s\n\r”,role_friendly_name[role]);
    printf(“*** PRESS ‘T’ to begin transmitting to the other node\n\r”);


    And because the ethernet shield use the pins 10,11,12,13, I had to disable the W5100 chip adding the following code:
    void setup(void)
    //disable the W5100 chip
    pinMode(10, OUTPUT);
    digitalWrite(10, HIGH);


    Obviously I changed the originary pins 9 & 10 into 8 & 9 as follows:
    // Set up nRF24L01 radio on SPI bus plus pins 9 & 10

    RF24 radio(8,9);

    Can you please help me to figure this out?

    • There’s nothing obvious here. For help sorting out issues like this, I recommend the Arduino forum. Zeroes everywhere is a sure sign that something is hooked up wrong.

  65. Johann

    Hi Guys I have a few of these units lying at home and cant get them to work , I found this site lastweek and have been trying to get the” getting started” example working but with no luck, checked all the wires 4 times made all the libraries local in the Pde to try cancel out file path issues , but still nothing when i start the serial monitor next to all the Config print lines I get 0xff so it seesm like the radio doesnt int. properly . any ideas?

  66. helo maniacbug

    i’ve tried this in arduino leonard and succed, but when i tried to arduino leonardo, the serial monitor just show me this :

    Got Payload 4294967295…sent response.
    Got Payload 4294967295…sent response.

    and always be like that..
    can you help me out?


    • Copy the result of “printDetails()” call to pastebin, and paste a link here. I think you’ll see it’s all zeroes, which means the modules are hooked up incorrectly.

  67. Tom

    I’ve used your library to create a simple rf link based on the ping-pair sleepy example. It worked a treat and was super easy to get going.

    I was wondering if you (or anyone else) have tried using the RF24 library with the standard Arduino SD card or Ethernet libraries?

    I want to use those two libraries with the RF24 library to create a networked data logger with a remote RF link to sensors.

    I have two issues, firstly all the libraries use a lot of ROM, any advice where to thin down the RF24 library to save some bytes?

    Secondly, it seems to me that the SPI interface for the W5100 and SD card on the Arduino Ethernet shield is set in Mode 0, while the RF24 library sets the SPI interface in Mode 3, and when I enable say both the RF24 and SD (in that order) the RF link fails and the SPI is obviously reading back garbage from the RF module. So I am pretty sure the SPI interface is getting messed up.

    From a quick look at the Nordic, Wiznet and SD data sheets it seems like they all can work using the Same SPI interface mode… Can the Nordic work with the same SPI mode as the others? Am I mistaken?

    I plan to spend some time debugging this, but thought I’d ask if anyone else has already crossed this bridge?


    • Hi. Thanks for writing, and I’m glad to see you found it helpful.

      The issues you raise are both certainly legitimate. RF24 is optimized for RAM use and ease of implementation, not ROM use. If I recall correctly, the library itself uses something like 3K RAM. Out of 32K, that seems pretty reasonable. If that’s getting tight, you could try removing all the strings, but even then, it’s probably best to just program directly to SPI instead of using a library when optimizing strictly for ROM.

      Yes, interacting with another SPI device requires care. It would be better if RF24 saved the SPI state, then set its own state when activating chip-select, and then restored it back to the previous state when releasing chip-select. But it doesn’t do that. So usually when I interact with another SPI device, I do that state management in the OTHER device.

      • Tom

        I sorted out my issues with SPI, the problem was (as with most queries here) to do with the wiring – 2 SPI devices on the one SS pin. I also must have read the code incorrectly because the SPI Mode is the same for the RF24, SD and Ethernet libraries, confirmed by printing SPCR before and after calling each xxx.begin() function. I have all 3 SPI devices working together quite well now along with an I2C device.

        As for saving memory, well I gave up in the end and got myself an Arduino MEGA 2560. I realised my time is better spent writing my own code rather than trying to debug errors introduced by me trimming down the all libraries I’m using. If it ain’t broke don’t fix it. The cost of the MEGA easily justifies the time saved in this case and the extra memory gives me the flexibility to do a lot more with the ethernet interface.

        Thanks again for the library it is a real time saver.

  68. baikis

    great tutorial. will it work with attiny85 chip? any ideas how to shrinkify this project?

  69. Hi Thank you for all the info. My question is, can the nRF24L01+ be used to send pin input states to my wireless network?
    I’m sending my koi pond pH readings with a 0 to 5V input to pin 0. With my ethernet shield connected to an extra Linksys with DDWRT, I’m able to wirelessly send that info to me home network and the internet.
    I’m looking to eliminate the Linksys and hope to use the nRF24L01+ somehow.

    • No, these radios will not operate on your home wifi network. To send pin states on your network, you could hook an Arduino up to an Ethernet sheild AND an RF radio as the receiver. So the receiver would hear the pin states from another RF radio, and then turn those into Ethernet messages which the Ethernet sheild can send out.

  70. I tried the getting started but kept getting failed errors. If I remove the wire to Arduino pin 13 and connect the radio ground to Arduino pin 8, it seems to be working.

    Got payload 4294967295…Sent response.

    Any idea what’s happening?

    • Probably the wires are not hooked up right. Use the getting started sketch, and post the result of the “print details” call in a pastebin, and drop the link here, we can have a look.

  71. It turns out that my radios have 10 pins. 1 & 2 are vcc. 9 &10 are Gnd. I made the change and it’s working.
    Are there any quick and easy ways to send pin voltage readings to the other board?

  72. Matt

    Hi maniacbug, thanks for all of the tutorials and information on your site, apart from filling my head with too many great ideas it has been an enormous help. I was wondering if you’ve tried using your RF24 library and the chip with an atmega328p running off of the internal 8Mhz clock? I am trying to keep my hardware footprint minimal but not sure if the internal clock is reliable enough for this kind of communication. I would only need to transmit at the lowest speed possible (250 kbps I believe?) since it is just basic sensor data.

    Thanks in advance,

    • Hi, no I have not used the internal clock. The variance looks pretty high, so I’d be surprised if it could properly keep the SPI bus running. That said, you could probably turn the SPI bus down to the lowest speed setting. It might work! Though to answer your question, no I have never tried it. Good luck!

  73. Serge C.


    Please I need some help; in the: Example for Getting Started with nRF24L01+ radios,
    - “Set up nRF24L01 radio on SPI bus plus pins 9 & 10 ”
    I have no problem with the SPI bus connections to the Arduino, but what do you mean by “plus pins 9 & 10″ ????

    Thank you for your help,


  74. Jim

    Hi maniacbug,

    I’d like to start off by thanking you for the library–I am so new to all of this stuff it makes my head spin!

    Anyway, I seem to be having a similar problem as the other newbies on here (I read the entire discussion log :( here to see if there was a common fix). I having quadruple-checked my wiring and can print the debug message to my serial monitor on both of my Uno’s (a regular version and SMD edition), but I cannot succeed with any pings using the “Getting Started” sketch. Please find my serial monitor output below (I used an image because copy/paste wouldn’t move everything… this may be the problem too because I see a couple of strange characters here):

    I switched back and forth between the two arduinos to no avail and tried uncommenting the…


    …line to improve reliability? Again, no success with this either. Have any ideas what might be wrong?

    Thanks a ton,


  75. Hi there, i am using your library but i am having several troubles with comunication! Sometimes it work, sometimes it fail, even if i try to resend the message 5 seconds after! I have to wait a biger time or reset the arduino on the button, sometimes the arduino led “lock” on like a loop when sending the message!

    Here is the code of the comander, who send and recieve the answer ( ), he recieve the message from serial, parse the message (json) configure the address and them send the message, them wait for a time before get timeout, but sometimes i get timeout here and sometimes i even can send the message. Model: Duemilinove

    Here is the code of the Arduino who recieve de message and send the answer! ( ) Model: Uno Rev1

    The conection with arduino is ok, since it work! But i need to make it more reliable!

    Sorry for bad english!

  76. hsdutra

    could someone do the work with arduino 2560 nRF24L01??

  77. Helo maniacbug, i’ve been using your library for 3 months, and i love it..
    but, i want to shrinkfy the arduino into attiny84 like this link below

    can i still using nrf24l01 with your library?

    thanks in advance

    • jme

      hi. I am also trying to do this, but using the attiny44. Did you sort it out? I am trying to write functions for the SPI from USI but it’s a bit tricky and difficult to debug! I think want is needed is setting USI on the correct mode and then create a transfer function like the default SPI.transfer call in the software. Would this be correct maniacbug?

      • Good luck! If you get it working with USI, please write up a post somewhere and drop a link here. I have never worked much with USI, but yes it does look like it should work!

      • jme

        I have almost converted it over, the only error i get that is preventing me compiling (for now!) is to do with PRGMEM
        is there any reason why that child_pipe needs to be defined as PROGMEM?

    • Not directly. You’d need to do some work to port it to USI.

  78. Joey

    Hi….This is a great software library! With it, I have designed a transmitter/receiver system that is working, although I am not sure it is working as well as it could be. Both my transmitter and receiver are 328′s. The transmitter only transmits. The receiver only receives. I am not using CRC or ACK packets.

    My transmitter is sending 4 32 byte packets to the receiver. It basically fills a 32 byte string and does a radio.write command 4 times in a row. I think the transmitting is stopped while the string is refilled for the next write, which results in the ~130 usec delay while the radio resyncs.

    Could you tell me what the best way to write 4 (or more) 32byte packets to the radio would be? Basically, I want to fill the tx fifo buffer and keep data in it until i am done sending.

    • Yes, you are running up against one of the design constraints of the library. The library is optimized for easily sending off intermittent bursts of data, like sensor readings. It does not handle high throughput very well, and your example illustrates it perfectly. Managing the buffer in such a precise way as you describe is outside the scope of RF24′s current capabilities.

  79. Hello maniacbug,
    first of all thank you for the great job you have done with NRF24.

    I would like to ask you if there is any way to send a broadcast message. I mean one sender and multiple receivers.
    If yes, do you think is it possible to do the opposite? One receiver for multiple senders?

    Thank you in advantage.

    • You can definitely have one sender and multiple receivers or one receiver and multiple senders. You will want to disable auto-ack in each case, and so you’ll have to handle detection of failed transmissions and re-transmissions yourself. You can refer to the data sheet for more detail on these concepts.

  80. Hello everybody,

    I’m trying to run this Getting Started, but isn’t work, help me. I’m trying to do this for 5 months.

    I have this questions:

    1 – I build my own arduino following this tutorial:
    2 – The arduino only have a serial port that works at 9600 kbps (I change the getting started and windows configuration to 9600)
    3 – I bought the NRF24 radio, but isn’t the nordic (plus version), it’s only NRF24L01. Will getting started works for it ?

    This is the log:

    What is wrong ?

    • Yes, everything in this post will work find for the plus or non-plus. Looking at your debug output, when we see something like all 0xff’s, that indicates the wires are not hooked up correctly. The Arduino is not able to talk to the unit. So either wires are hooked up incorrectly between the two or there is problem with the power to the unit, or the unit is not working.

  81. stefan

    Sold out …… :-(
    Im so sad, and a little angry ;-)
    I guess thats because of the hype.
    Maybe next time..

  82. Do you have any plans to port the library to the new Arduino Due 32bit?

    • Someday! I imagine I’ll get an Arduino Due someday, and yes that day I will port it over. It already works with Maple, which is ARM-based, so it should not be hard to port it to Due.

  83. Is it possible to use your library and have more then 5 nodes on the first level?

    • I will need to make some changes to the library probably, but is it possible to communicate using this hardware more then 6 nodes? Or it is a hardware limitation? I have a base station where my leaf stations send information once in a while, but there is more then 5 leafs and I don’t want to create a relay station and use more leafs because in this way I will have other station just to retransmit the messages to the base…

      • You can use more than 6 nodes with this library, but you’d need to divide them into a tree. For example, you could have 2 relay nodes, with each having 2 children.

        It’s a software limitation in that it relies on the capabilities of the hardware to handle communicating with multiple radios at once. Since the radio can easily handle 6 at once, the software takes advantage of that. A more complex network layer could do much more, which would be much more powerful of course.

    • Depends which library you mean. RF24 is a simple radio driver, and doesn’t know much about nodes or levels, so you can build what you like atop it. Perhaps you refer to RF24Network? That library is optimized for the 6-pipe functionality of the chip, so it uses 5 nodes at all levels for simplicity. You could perhaps modify the library to get that to work, but you also may want to write your own layer that’s more tuned to just what you want to do with it.

  84. Jeen

    Hi Maniacbug, i’ve been followed your work for some months. Last week i got my Arduino Uno and nRF24L radio modules. I’ve downloaded both with Getting Started code from Example. However i can’t make both of them to communicate. I noticed from the code, the //radio.setPayloadSize(8) has been commented.
    Is this the actual need? I have saved the printDetail() output. the link Please help. Thank you.
    //if ( role == role_ping_out )

    • Jeen

      Hi ManiacBug,
      After spending almost two weeks on checking and swapping hardwares, finally i manage to get it working. My problem is my radio modules (SPI) aren”t 5V tolerance. Although it is stated on the radio module that the com and control lines are 5v tolerance, but somehow it is not!
      What i did was, i breadboarded myself two arduinos with two Nordic radio modules running at 3.3V, and the there is it. Thank you. ManiacBug.

      • Glad to see you got it working! Typically the inputs are 5V tolerant but the power is not. Still, it can be flaky, so yes the sure-fire thing is to use 3.3V throughout.

    • The examples should work without modification. What did the output look like on your transmitting node?

      • Jeen

        Yup, you are right, no modification is needed for the examples. I’ m using PingPair example, i grounded the role pin to make it into transmitter.
        The transmitting output is like this;
        Now sending 106…ok…Got response 106, round trip- delay: 27
        Now sending 1139…ok…Got response 1139, round trip- delay: 28
        …….and it goes on.
        I’ hv been followed your blog and comments very CLOSELY! Ha Believe me, i has been reading the QnA in this blog for several time. There was time when i read about how others has done on their tries. It gives me the dynamic to continue to explore the wonderland! It is the learning curve that i need to go through.
        Now I planned to try on your RF24 Network, the Network project is just awesome. Again, Thank you. ManiacBug.

  85. Thanks for you’re help here previously, you might like to see my project:
    Using the nRF24L01+, Arduino and Nike+


  86. Javier

    Hi, First of all let me thank you for the post it is great! I have a few questions if you don’t mind, what are the units for the time that it takes for the signal to “bounce” back…I’m asking this because I am assuming that it all happens on GHz…since this is the transceivers operating speed, can the arduino handle this, given that it operates at MHz? (correct me if I’m wrong). Thing is that I want to create an alarm that will activate when breaching a perimeter….I’m thinking of measuring the signal based on the “bounce back” values, when signal takes too long, it’ll beep! Any help will be greatly appreciated!!! Thanks!!

    • If I have two nodes sitting right next to each other, they usually return a ping back in about 25 milliseconds. In that time, the Arduino can process 400,000 instructions. So, plenty of time!

      Ignore ‘GHz’ and ‘MHz’. They refer to completely different things.

  87. Jay Rabe

    Have not read all the posts yet, apologies if the answer is there. I’m a couple of weeks away from breadboarding first attempt. But looking forward, does your library support downloading a new program to slave nodes via the RF link?
    Thanks for a GREAT blog!
    Jay Rabe
    Portland, OR

  88. Elliot

    I will be testing this with the TI launchpad and Energia once my shipment of 8 transceivers comes in if you want updates

  89. Korey Haug

    Working on a build project where we are trying to fly an RC plane with an arduino from the ground. Is your library only for two arduinos interacting with each other, or is it possible to send data to the transceiver on the Ready-To-Fly plane? Our plan was to set up the transceiver to listen to the remote controller to see what the data signals look like, then, once we know the commands, send them ourselves from the arduino to the onboard flight controller. Thanks for any advice or comments!

    • You could send data to the transceiver on the plane, IF you know the communication settings and the protocol. These things are difficult to reverse engineer. But once you have them, and if they are using compatible RF signalling, then yes you should be able to do this.

  90. Elliot

    So I’m working on porting this to Energia (arduino for TI Launchpad), and needed to remove all of the PROGMEM stuff because it isn’t supported. What bug did you remedy by storing those char arrays in flash and not ram?

  91. Chris

    Hello, and thank you for the library. I have a question about how to set up two sending units, each sending a different payload to a single receiver. In my case, one sender is providing weather/environmental data, and the other is providing power usage:

    struct payload_t
    float data_Temp;
    float data_Pressure;
    float data_Humidity;


    struct payload_t
    float data_Voltage;
    float data_PowerP1;
    float data_PowerP2;

    How can I instruct the receiver to differentiate between the two payloads? I didn’t see anything in the examples that would show how to do this?

    • The canonical way to do it would be to add an ‘uint8_t payloadtype’, and then set it to 1 if it was the first kind, and 2 if it’s the second. Inspect the first byte, and then decide from there how to handle the whole payload.

  92. Alex

    Hello Maniacbug,
    Firstly thank you for such a well written and document library, fantastic work!

    I spent about one week trying to get two Nano V.3 to speak to each other. In the end I had two issue. First issue was the 3.3V supply from the FTDI chip. This must be noisy or something (I don’t have a CRO so not sure) and in the end I had to put a capacitor between pins 1 and 2 on the nRF24L01 module (33uF I had lying around).

    Second issue was the PA level. I had to set this to low in order to get the two units sitting on the same desk to work.

    Just thought I mention these two issues in the hope of saving anyone else the grief.

    Thanks again,


    • alfredosandes

      Hi Alex,

      I am trying right now to make two arduino nanos talk through the NRF24L01 chip. I understood your comment about the 3.3V noise and I am about to try to fix that up. What to you mean, though, by PA level?

      Thank you,



  93. Mansoor Khawar

    Hi Maniacbug, I highly appreciate your efforts to make this complex module use so easy and the kind replies you give everyone. I am a newbie. Not so good in programming (just at Beginner level). If am making my final year project and i need to use this module with arduino uno R3. I just want to transmit some bytes and receive on other module. Can you guide me where i put and get data in the code?

  94. Stedew

    Stupid question is there a reasonable easy way to compile the NRF24 in a “regular” gcc project (preferable in AS6) i have converted the ledtest programm to run in AS6. that’s handy because so you can use the debugwire to debug some cases. but i rather should run native C++ So to make a long story short: Are there others thinking on this ?

  95. Joel

    I am using a seeduino and and arduino with a radio module each. When transmitting from the arduino to the seeduino the seeduino receives the payload but the arduino does not receive a ping back. When transmitting from the seeduino to the arduino the arduino does not receive the payload. I can’t find whether the fault lies with the seeduino or the arduino

  96. Thanks for making this library. Played with these radios today (NRF24L01+) and they are good for reaching anywhere inside my house and about 35-40 meters through a window :)

  97. Hi,

    Figured it out: bad pin on the Arduino clone board I was using on one end of the connection! SainSmart Uno – love that board, had it awhile, but evidently I just didn’t find the bad pin until now or it failed at some point along the way. A new Arduino Uno R3 and everything hums. Thanks anyway!

    Again, thanks for the library work. All the best to you!


  98. Dale Barnard

    Hi Maniacbug, first I’d like to say thanks as your library and advice allowed me to complete my 3rd Year Uni project of building an autonomous lighthouse, I’m now pursuing my own project – that being to program the Arduino itself wirelessly using the NRF24L01+, do you think this is possible? There are products out there, such as the Synapse RF100PD6, the Sparkfun BlueSMiRF module and the XBee that can do this so I wanted to investigate to see if I could produce a lower cost equivalent, any thoughts?

  99. Hi Maniac,
    Successfully tried RF24 examples and are perfectly working now in Pakistan and am teaching in workshops and class and specify on as well.
    Consider LED and Remote example and after perfect communication between both units we plugged a temperature sensor and distance sensor on LED Board Arduino. Later we plug more sensors if all parameter pass correctly. I plug these or many other sensor on one side in respective pins and get the desired values and data calculated on the same unit and displayed them on terminal.
    Rather to transmit all parameters passed one by one [Temperature - pressure - Humidity - GPS position and so on] – why not merge all together and send them in one packet as we have enough bandwidth available – we are able to and can transmit full merge packet in one go.
    How to combine the variables and merge info together to send ? Can you help me on this.
    What is the best way and method of doing this.
    Promoting Micro controllers and Arduino in Pakistan . Any one student or professionals can get help and components
    Kaludi Athar – Pakistan

  100. Matt Morris

    Another pointer for those trying to get things working on the “GetStarted” sketch.

    I got this working on ATmega328P/3.3V/12Mhz (using a recompiled Optiboot for bootloader). Two problems. (1) I did the standard mistake of mis-connecting cables (so didn’t get the addresses coming out properly, that was relatively easy to fix), then (2) once that was fixed I was getting maybe one ping in 10 working.

    This latter problem was driving me crazy. I was trying one channel after another, recompiling with serial debug turned on, all kinds of things. But it turned out that everything in the library was working absolutely fine and the issue was that I was powering both breadboards via a single USB programmer (linking ground and Vcc between boards). This turned out not to supply enough power for a reliable ping. Once I directly powered the breadboards via a 3.3V voltage regulator to mains, I got 22-25ms pings 100% of the time immediately.

    So assuming you hook up cables correctly and supply some decent power, the RF24 library + examples work fine in a 3.3V/12Mhz ATmega328P world.

    A big thank-you for putting this together. I can now get ATmega328P+wireless+sundry components for less than 5 GBP per set, which is ridiculously cheap. I’m going to be using it initially to control some LED programmable strips from a central point. The 1 meter acrylic pipe I’m putting each strip of LEDs in (needs to be frosted to diffuse things) costs more than the electronics driving the strip!

  101. Zeog

    I am having trouble getting the basic Getting Started to work, and not sure what to try next.

    One nRF24L01+ on a Uno, one on a Mega, using the relevant SPI connections for each.
    They have 3.3v power from the Arduinos. Have quadruple checked the wiring.
    Have tried from about 1m to 4m separation between radios.
    Both initialize and print the configuration as expected, so SPI seems to be working.
    The getting started sketch operates as expected (using T and R, from either end), no errors except that there is never a successful response.
    I can use the scanner sketch and see light interference at the low end (wifi channel 1 probably from the channel spreads) so testing carrier seems to work, and there’s hardly anything detected near channel 4C.
    Using the scanner on one, and using Transmit mode of the Getting Started sketch on the other, I can see RF on channel 4C from the other unit (a smattering)
    If I make a modified sketch which sends packets more rapidly, I see lots of carrier counts on Channels 4B and 4C, when using scanner on the other unit, so it is putting out RF that is detected as a carrier and CE must work. Turn off the transmitting node, the carrier counts go away on the scanning node, so I am definitely seeing RF carrier from the other unit.
    I tried swapping with a spare nRF24L01+ unit, no change.

    So power and connection seems good, it seems to transmit something and to detect carrier from the other unit. But there is a total failure to communicate.

    What else can I try?

  102. Hi,
    I have ordered for two of these modules. In one of the arduino I plan to add a enc28j60 module also. Is is possible? Will the RF Module and ethernet module clash with each other? My gameplan is to put a RF module in sensors around the house and connect them to the central arduino with a RF Module. This will then connect to internet and give me notifications via Notify My Android. Any suggestions of similar project you have worked on.

  103. U-hyeon

    At first, I tried SPI communication between two UNO R3 It works fine.
    But, when I tried to SPI communication between Mega 2560 and UNO R3 but it didn’t work.
    Could you tell me what to do?
    Mega Pin Map
    and the code is same.
    Thank you for your time.
    Best regards,

  104. Fantastic library, how-to and comments/answer thread, truly the sort of thing that is best about the internet!!
    I was able to get a link up and running within minutes using the ridiculously cheap modules – £2.54 for a pair with free shipping from China! It actually has a 24L01+ chip on it. I was very dubious because of the non-existent documentation and shoddy appearance of the website, but they delivered in a week or so.
    Next stop is to try using the SoC nRF24LE1 rather than a microcontroller and radio in seperate chips – I’m desperate to minimise the BOM as space/weight is very tight. I’ve just ordered these –
    BTW I’m working on a wireless badge idea – they will communicate with each other and send small messages and glow different colours – and I’ll come back and post a link when it’s documented.
    Many thanks again maniacbug (and other contributors) – much appreciated.

  105. Chris

    I am using the NRF24l01 library (not the network library) and it is working well. However, I’m experiencing an issue that I can’t seem to determine the cause.

    I have a sending unit and a receiver. i first establish that they are communicating by sending one byte and if I get an ACK then I know they are both talking to each other. Then, the receiver goes into a subroutine for 8 seconds or so taking some readings from a sensor and doing some math. During that time I do not check the network radio.

    Then the receiver starts loop() which constantly checks some sensors and the radio input. I seem to lose what was sent during the time that the receiver was in the subroutine not checking for data. I thought I read somewhere that there was a receive buffer and I assumed it would hold the data till I checked again. Is that incorrect?

  106. kobiben

    Hello back,

    for anyone that is interested, I solved my problem, after very long hours or trying, bottom line the only thing that worked was to connect a voltage regulator of 3.3v to the arduino VCC and GND pins and take the Vout into the nRF24L01 module.
    any other solution did not worked, even using a USB power adapter did not work. I ended up buying a L78L33 from ebay.
    please note any direct external power source into the radio module caused it to display crazy and unstable values on all details printed from the radio.printDetails() call.

    hope to help someone out there.

  107. Edgar

    what was your problem???

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s