Tuesday, May 28, 2013

nRF24L01+ Arduino Communication on Arduino Mega 2560

Disclaimer: Note the last paragraph.

In my quest to explore inter-Arduino communications, I bought 2 nRF24L01+ modules. These are pretty neat radios. From what I have read, they are AM. They can be used with key fob remotes or in a network of up to 6 modules. They are also very cheap. My 2 were $3 on Ebay, but many vendors sell them.

When I first began working with these modules I needed a way to interface with them. Wanting to
breadboard at least one of them, I created the adapter shown to the right. It isn't a perfect solution. The module itself gets in the way of wiring slightly, but my jumpers fit in there good enough.

Next I loaded the RF24 Library. HERE is a blog post by maniacbug that details using the module on an Arduino Uno. It is very useful. THIS page also helped. However, I don't have an Uno. I only have an Arduino Mega 2560. This means that we need to change a few things.

First, we need to change the pins. The Arduino Mega's SPI pins are in different positions than the Arduino Uno. You can figure these out pretty well or you can look below.
          Uno           Mega

  • 11       -      51            (MOSI)
  • 12       -      50            (MISO)
  • 13       -      52            (SCK)
  • 10       -      53            (CSN)
  • 9         -      40 (Your choice) (CE)
Another note, IRQ is not needed for anything I will be discussing. Just leave it unplugged. 

Second, the code needs to be changed slightly.
RF24 radio(9,10);        needs to be changed to      RF24 radio (40, 53);

On the receiving end, I decided to use my Hackduino. Since it is basically an Arduino Uno, the pins are wired the same, and the example code does not need to be changed at all.

However, I did have the problem of needing a 3.3V power supply. Well a few minutes and a Google search later I found THIS calculator and built my first voltage divider circuit. I used a 470 Ohm resistor between 5v and output. 220 and 22 Ohm resistors in series (for a total of 242 Ohms) were placed between output and ground. I read it with a volt meter and it was right on the money, 3v3.
3.3v voltage divider
Black: GND   White: 5v    Green: 3.3v output

Well here goes nothing. Open the serial monitor and type t. I got this screen.

The first part of that is fine. The second is not.

Well I did some digging. While I had found two forum threads (HERE and HERE), I had not found them terribly useful. They came to the conclusion that he Arduino Mega power supply was the problem. While this may be the case, no combination of capadcitors seemed to fix it. I also went on to try the power supply from my Hackduino, 2 AA batteries, and the 3.3V supply on my breadboard power supply. None of these things worked.

I did successfully get it to send once, but I have no idea how. It just worked. I unplugged the USB and plugged it back in, and it didn't work. I have rung out every jumper I am using and have tested all the pins with an LED. I swapped my two RF modules out. Same problems. At this point, I really have no clue what the problem is. I don't have an Arduino other than this one to try it on. I also don't have a variable power supply to test with.

Well that's all I have. I admit that I am quite disappointed with myself for posting an unsuccessful project. I don't know if I will continue working on it or not, but if I do get it working I will post an update. I may try the Mirf library, but we will see. I only paid a few dollars for these modules, and if they are bad I don't want to waste any more time on it. If anyone has any suggestions, feel free to comment. Regardless of my apparent failure, I still learned quite a bit in this endeavor. I hope you have better luck!



  1. DEAR SIR,
    i wanted to do same thing but want to transfer the cctv video through this appratus. will it work ???

    1. While it may be possible, it is certainly not the typical use of this module. Iknow there are ready-made solutions for wireless cctv video out there. I'd have to research it some more though.

  2. Hey Matthew - I am trying to get these radios to work as well,

  3. Well good luck to you. If you get it working, i'd love to hear about it. Someday I may revisit these, but I'd still recommend you check out bluetooth if you have trouble. I bought a $10 bluetooth adapter and had it working in 30 minutes. Much less frustration.


  4. Mattis Gärtner NilssonDecember 3, 2013 at 4:21 PM

    I have the same problem but I had mine running for days before they died. Tried with different modules bit no difference. It is really driving me mad since I didn't change anything. My latest thought is that is has something to do with noisy voltage regulator as some people seem to have a problem with that. Solved by putting a capacitor in the circuit. However I didn't have one at home so I have to try that when I get one. Try Google nrf24l01 not working capacitor or I can find it for you.

  5. That is good to know. I haven't touched mine since I wrote this post. That does sound like a plausible explanation. I know I tried putting a capacitor across it, but I think all I had was a big electrolytic. I could be wrong though.

    Shortly after writing this I tried a little bluetooth module for wireless communication. It worked brilliantly. Really the only issue with that is making sure you get the right module for your application. However, if I ever decided to do a project that required Arduinos talking to each other rather than to a computer, the nrf24101 would be the way to go. I just got tired of messing with it.

  6. Mattis Gärtner NilssonDecember 3, 2013 at 6:23 PM

    I used it for communication with raspberry pi, worked real great. BTW just got it to work again for some reason but only on mega and the pro mini is the important thing to get it working with. Will try again tomorrow.

  7. Mattis Gärtner NilssonDecember 4, 2013 at 11:44 AM

    Just for the record, today I added a 220uF (according to other forum knowledge, about 50-100 is probably enough though) with success. I soldered it right on the nrf24l01 pins sticking out on the circuit-side of the board.

  8. I'm glad to hear that. You've gotten me interested. Maybe during the holidays I will pull mine back out and invest a couple hours in it. I had given them up as a lost cause. Thanks for your information.

  9. i've used external 3.3V regulator for NRF VCC and it worked!

  10. Well that's good to hear. I suspect my modules may have just been flaky. If I ever revisit this I will probably get another pair to use.

  11. After a bit of experimentation, I have the nRF24L01+ running smoothly with the Mega 2560. The trick was to add a (relatively) large smoothing capacitor between GND and 3.3V in addition to one on the radio. In my case, I used a 2200uf near the board and a 100uf soldered directly to the radio module. Also, I had to wait around 10s before bringing up the radio to allow the larger cap to charge up. From that point on, everything seems to work correctly. I may come back after experimenting with smaller caps. 2200 seems overkill, but it was the first thing I grabbed, and worked.

  12. Just found this blog, and these comments. As soon as I added the capacitor as suggested, it worked like a charm. Haven't tested range yet, but it works indoors from one room to another!

  13. Hi! What is the capacitor you are using in that pic? is it 100uF? Thanks!