The, Very Frustrating, NRF24L01+

(See also, Testing 433MHz RF Modules)

I have tried out many different devices with the Arduino and generally I can get a simple test working pretty quick on even the most complex. That sure hasn’t been the case with the NRF24L01+ RF transceiver. It seems this device is pretty finicky.

It has taken me three tries to get this device to run consistently. Partially due to my own mistakes. No, I take it back, largely due to my own mistakes – mainly not taking others’ advice.

The Hardware

The base transceiver is the NRF24L01+. It has a range of about 200m (67′). It is small and self-contained. Not much bigger than a large stamp. I got 4 of these on eBay for maybe $4. They are *really* cheap.

nrf24-fig1

These are the first units I tested. They worked OK in the same room and reasonably well with one wall between them (next room). They dropped too many packets at 50′ and a couple of walls in between  to be useful at that range.

The NRF24L01+PA+LNA has a power amplifier and Low Noise Amplifier to increase its range to a reported 2000m (666′). Some how I ended up with just one of these so I tried it with the NRF24L01+ and the range wasn’t any better. So I waited for another shipment from China so I had two NRF24L01+PA+LNA. These worked better only after tweaks explained further down.

These are *way* more expensive. I think I paid $6 each.

nrf24-fig2

Connecting the NRF2401L to an Arduino

I used a Nano on this project, but the Uno will use the same pins. You *really* want to be using an external 3.3v power supply to power this device. See my Gotcha’s below. Check the sketch as to if you need pin 8. For my test, I did not.

nrf24-fig4

Software Library

I used the RF24 library available here. Download it, unzip it into a directory named RF24, then move that directory to the arduino libraries folder (where all of your other libraries reside).

The sketch I used is found at Examples | RF24 | GettingStarted. This sketch should require no modification to get two of these devices communicating. Compile and download to your two Arduino’s with the NRF2401’s connected.

The arduino IDE doesn’t seem to like being open two times and pointing to 2 different COM ports. I didn’t try to deal with this, as I almost always use a different terminal emulator to begin with. I just ran 2 copies of it, each pointed to the proper serial port.

Note that the default sketch uses 57,600 baud. Make sure you set your terminal emulator properly or you will just see garbage.

When you first connect to the NRF24L01+, it will be in receive mode and you will see a information dump about like this:

nrf24-fig5

You should not be seeing a bunch of 0’s and CRC Length and PA power should be as you see above. If they are not, you probably are not connecting to the NRF24L01 properly.

Once you have both Arduino’s at this point, type “T” on one of them. This will toggle that NRF24L01 from receive mode to transmit mode (you can return to receive mode by typing “F”).

This is one point where I was having some problems. Some times just typing T on one arduino wasn’t enough. I’d have to toggle back and forth on both arduino’s until they just started working. That problem seems to have went away once I resolved all of the gotcha’s; however, if you press T and you don’t start seeing transmission, you might try toggling both arduinos a few times.

If you are lucky you will see this (this is the transmitter side):

nrf24-fig6

Gotcha’s

As I said, I had a lot of trouble actually getting this to work well.

First, you should solder at least a 0.1uF capacitor between pins 1 & 2 (GND and Vcc) ON THE NRF24L01+ especially if you have it connected via jumpers like I do:

nrf24-fig3

Next, you need to provide external 3.3v power to the NRF24L01+. This YwRobot power supply I’m using can provide 5V on one side of the breadboard and 3.3V on the other.

There are multiple resources that document needing the capacitor and a better power supply. You might want to heed them so you don’t get as frustrated as I did.

Even after I made those changes, I was still having issues with packet loss. I decided to power the Nano from the external 5V power supply and it began working much more reliably.

I only made these tweaks once I started testing the NRF24L01+PA+LNA. Once it was running well, it would go diagonally thru my house from the basement in one end of the house to the 2 floor at the other end. That is roughly 75′ thru 2 floors and multiple walls.

I have not tested the NRF24L01+ with the tweaks. They may well work a little better too, but they aren’t rated for much distance to begin with.

Scanning the 2.4GHz Spectrum

For my my last test, I compiled and downloaded code that allows the NRF24L01+ to scan each channel and give an indication of what part of the spectrum is in use.

I used this blog post as my reference which includes the source code to the scanner. I downloaded and compiled the software w/o changes (note the serial port is 57.6KB).

Here are my results:

nrf24-fig7

Each column has a ‘grayscale’ character indicating power: ” .:-=+*aRW”. A space is lowest and W is highest.

I puzzled over these readings. I checked my WIFI access point in that room, and it is on channel 11 and I know that channel is in moderate use because an IP camera is on it. I could not explain all of the traffic on channel 5.

Then it occurred to me I have an analog wireless surveillance camera that uses the 2.4GHz range. I turned that off:

nrf24-fig8

suddenly I can see a lot more traffic and the overall power level is way down.

Not sure how to interpret these results yet, but interesting.

Conclusion

As I think about it, I think this is the first wireless device I’ve used on an Arduino. Not exactly surprising as I’m not a big WIFI fan. The only wireless device I use regularly is my phone.

I’m not sure how much use I could get out of these NRF24L01+ units. The small ones could be handy, but their range is to limited for me. The NRF24L01+PA+LNA seem to do well within the confines of my house, but with the whip antenna are not exactly small. We’ll see if I come up with something for these down the road.

It’s on my list to test a cellular GSM shield and the new ESP8266 WIFI module. Both seem to be more suited to my interests.

 

 

 

 

This entry was posted in c-arduino and tagged . Bookmark the permalink.

6 Responses to The, Very Frustrating, NRF24L01+

  1. Sean Straw says:

    The cap on the radio connector is to deal with the fact that the ribbon cable itself it a sort of antenna, and will induce A/C noise. The cap helps to filter that out. If the radio pins were going straight into a GPIO header on an embedded device, the cap would be less necessary.

    I have a few of those same YwRobot breadboard power supplies. Got them fairly cheap, I think on DealExtreme – and then had to buy the male-to-male USB cables which aren’t commonplace. Recently I purchased several of a different design (and IMO, much improved) from a vendor on AliExpress. 2.1mm barrel plug on one side, and USB mini (the type found on a lot of older Motorola cellphones, so the wallwarts for them are easily found at recyclers), is selectable for 3.3 or 5V on either rail (so one side can run one voltage, the other a different if you want), AND the rail connections are “wings” that come down on either side of the PCB – so it doesn’t block use of any of the breadboard pins. One downside is that it doesn’t have a power switch. They were US$0.79 apiece.

    I’ve used a number of 315MHz, 433MHz, and 2.4GHz radio modules with reasonable success. They are very dependent upon good power. The 315 and 433MHz units are limited to lower data rates, but they have the benefit of not competing with WiFi, digital phones, and microwave ovens for bandwidth. However, the modules I have for those are Rx and Tx pairs – separate PCB modules. That’s a bit of a downer when I get them as pairs and mostly need Tx modules for my telemetry purposes, but at least they’re cheap, and easy to feed.

    • Jim says:

      I wonder if you could tell me…if I want to take the raw output from one GPS (RTK Base) and put it directly into the radio I set up as ‘TX’, then take the received signal from the “RX” unit and put it directly to the other GPS (RTK Rover), might that work? I am going to try it soon, but I thought I would ask.

  2. Larry says:

    Hello there.
    Very informative post for nrf24l01.
    I need some assistance from someone more experienced with these rf guys than I am.
    I want to control 2-4 servos. I want to use an Arduino Nano on the wall with a potentiometer and an rf24 sending signals to an Arduino Nano mounted in the mini blinds with a servo and an rf24 to open/close the blinds. Since you can use up to six rf24s in a network, I want to use an Arduino Uno with an rf24 as the master station. I want the Nanos at each window to be controlled by potentiometers as well as from my computer I have set up as my home automation controller. I’m using the Universal Devices is your-994iZw as the controller. Eventually I’d like to have the blinds adjust themselves according to temperatures, luminosity, or other parameters.
    I have the parts and pieces, just don’t have enough knowledge of nrf24l01 or coding ability.
    Any help would be much appreciated.
    GT

    • Dan TheMan says:

      This sounds like a very cool project. I have often wanted to open/close mine just based on time of day – never even considered temp. That is a great idea.

      I don’t really know where to direct you on this. It is highly unlikely you will find someone else who has written what you want which means you are going to have to do it yourself!

      But that’s OK! Programming MCU’s like the arduino is so easy now it doesn’t take much work to learn enough to do what you want to do.

  3. Evert says:

    hello it works fine for me. I use the prints with the large antenna. The capacitor is important. I bridge the distance between 3 rooms with two walls and all on low power. I don’t miss a package. greetings Evert

  4. Pingback: Testing 433MHz RF Modules | Big Dan the Blogging Man

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.