nRF24L01 not working with basic sketch

I am using 2 x Arduino Nanos and have uploaded the basic sketches as shown:

Transmitter end

/*
* Arduino Wireless Communication Tutorial
*     Example 1 - Transmitter Code
*                
* by Dejan Nedelkovski, www.HowToMechatronics.com
* 
* Library: TMRh20/RF24, https://github.com/tmrh20/RF24/
*/

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

RF24 radio(7, 8); // CE, CSN

const byte address[6] = "00001";

void setup() {
  radio.begin();
  radio.openWritingPipe(address);
  radio.setPALevel(RF24_PA_MIN);
  radio.stopListening();
}

void loop() {
  const char text[] = "Hello World";
  radio.write(&text, sizeof(text));
  delay(1000);
}

Receiver end

type /*
* Arduino Wireless Communication Tutorial
*       Example 1 - Receiver Code
*                
* by Dejan Nedelkovski, www.HowToMechatronics.com
* 
* Library: TMRh20/RF24, https://github.com/tmrh20/RF24/
*/

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

RF24 radio(7, 8); // CE, CSN

const byte address[6] = "00001";

void setup() {
  Serial.begin(9600);
  radio.begin();
  radio.openReadingPipe(0, address);
  radio.setPALevel(RF24_PA_MIN);
  radio.startListening();
}

void loop() {
  if (radio.available()) {
    char text[32] = "";
    radio.read(&text, sizeof(text));
    Serial.println(text);
  }
}

I get nothing on the serial monitor of the receiver side, the baud rate is set correctly.

Connections have been checked and double checked, they are as follows:

Same for both TX & RX

CE - Pin 7
CSN - Pin 8
SCK - Pin 13
MOSI - Pin 11
MISO - Pin 12

If anyone can point me in the right direction, I would be much obliged.

Hello
I remember having trouble dealing with those also.
What you can try do to do is

  • don't put the devices to close to each other
  • try to use external power supply
  • add a capacitor between Vcc and Gnd, the closest possible of the radio module
  • set the radio power to the maximum just to test

Are you using fake Arduinos? You can. Just asking because when I tried (a few time ago), it was working with some arduinos, and some others no ; without changing anything but the board

Add one bullet point in Post #2:

  • Do not use in a solderless breadboard (because the 2rowx4col pins will be shorted).

(maybe post a picture of your configuration)

Anthony,

Many thanks for your very quick reply.

I don't have any capacitors at the minute, will need to order some.
The transmitter side was plugged into a USB charger away from the computer.
They are Nano Clones, I bought a complete kit with two Nanos, two nRF24l01s with separate antennae and two adaptor boards.

Thanks
Steve

Thanks for the quick reply, the leads are all directly wired, no breadboard used at all.

Cheers
Steve

But where do the radios get their voltage? If you are feeding it from the 5 volt pin, it may not matter what you feed the USB gazinta.

Use a decent power supply and power the module directly if you aren't.

And by "away", just how much distance is between the two radios?

a7

a7,

Thanks for your reply, I and using a 3A usb charger for the transmitter, with the receiver being plugged into a USB port on my computer.

The two units are about 1500mm apart.

Cheers
Steve

You can't plug the receiver into a USB port! Unless you've omitted something in between the two.

Just confirm you are feeding 5 volts directly from a power supply, not using the 5 volt output of the Arduino board.

OK, that's a start. 3000mm would be better. Even though you

  radio.setPALevel(RF24_PA_MIN);

a7

As the RX is displaying data on the Serial Monitor, I fed the Nano of the RX from my computer using the USB lead.
The TX is fed from a 3A USB charger.

To check that the Nanos were working, I loaded the blink sketch onto each and all was well. Following that, I uploaded the TX and RX sketches again. This time, I made sure only the sketch being uploaded was open. Everything is now working correctly.

Thanks for the help
Steve

A couple of questions if you don't mind:
1 - Are the power options just MIN and MAX?
2 - Is it trial and error to see what option works? the project I am looking at needs to transmit about 10m maximum through a window.
3 - What size capacitors works best? I have seen a few posts, some use 10 microFarads, some 47 microFarads and others 100 microFarads

Thanks
Steve

You can find the answers to most of your questions here:

& here

  1. Also RF24_PA_LOW & RF24_PA_HIGH You can also enable/disable the LNA if using a high powered module: radio.setPALevel(RF24_PA_HIGH, 0); to disable it via the 0.
  2. Pretty much, radio/wireless systems pretty much need to be tested in real life scenarios to see how they function in the environment.
  3. I typically use 10uF, but 47uF will work. 100 is a bit overkill. You see it depends on your power supply, you might not even need them with a solid power supply. In theory you could have a small (100nF) cap, + a large (10-47uF) cap to filter out noise and provide power. If running off batteries for example, a 0-10uF cap should be good.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.