Can not get NRF24L01 to work with 2 Nanos

I followed this post Simple nRF24L01+ 2.4GHz transceiver demo. As well as this youtube video All About nRF24L01 Modules - YouTube. I am using this RF24 library (Optimized high speed nRF24L01+ driver class documentation: Optimized High Speed Driver for nRF24L01(+) 2.4GHz Wireless Transceiver)

I have the exact same code uploaded to 2 Arduino nanos as shown in the video.
Code is below

Transmitter

// Code 1 : Sending Text (Transmitter)
// Library: TMRh20/RF24 (https://github.com/tmrh20/RF24/)

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

RF24 radio(9, 8); // CE, CSN
const byte address[10] = "ADDRESS01";

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

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

Receiver

// Code 1 : Sending Text (Receiver)
// Library: TMRh20/RF24 (https://github.com/tmrh20/RF24/)

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

RF24 radio(9, 8); // CE, CSN
const byte address[10] = "ADDRESS01";

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

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

An example of my output on my receiver nano is below. Above the last line symbols are just '\n' due to println. Most of the time the receiver is printing just '\n'.



B�!BB�

I am not sure what the problem is as I am followed many tutorials just like this to no avail. Any recommendations would be greatly appreciated.

What happens if you run the examples in Robin2's tutorial? Those are known to work. I use that code as the basis of many rf24 projects.

How are you powering the radios? The Nano 3.3V regulator will not provide the necessary current. Use a better external 3.3V supply. A 2 AA cell battery pack (3V) is said to work. I use homemade power adapters like below with good success. You can try the 10uF to 100uF cap across the 3.3V supply to bolster the 3.3V supply, but that probably will not help in the Nano case.

image

I tried your posted code on my 2 Uno boards with RF24 modules that I use for development. Those units have the external 3.3V supply in post # 2. The code works fine on my boards. The receiver prints "Hello World" every second.

That suggests a power or wiring problem. The solution to the power problem has been addressed. Run the checkConnection program (reply #30 in the tutorial) to check the wiring between the processor and the radio module. Post the results from serial monitor.

It is often helpful if you can post a schematic and photos of your wiring.

Some other tips:
If using the high powered radios make sure to separate them by a few meters. They may not work too close together. Try the lower power settings.

Reset the radios by cycling power to them after uploading new code. I have found that to help. They do not reset with the Arduino.

Switch to 1MB data rate to catch the not so well cloned clones.
radio.setDataRate( RF24_1MBPS );

Also for some clones, change TMRh20's RF24.cpp line 44
_SPI.setClockDivider(SPI_CLOCK_DIV2);
Into
_SPI.setClockDivider(SPI_CLOCK_DIV4);

Have a look at the common problems page.

The arduinoinfo Wiki.

The Last Minute Engineers rf24 page.

Pipe addresses are 5 bytes long, SS01 is just a senseless waste of RAM,
and it could bring someone to believe "ADDREF*CK"would be a different pipe.

If 32 bytes without the trailing zero are transmitted,
nobody can tell how much would be printed.
It does not matter for the simple example,
but a 33 byte buffer would always terminate the printing.

Schematic is below for both Arduino nanos. 5V is coming from 2 USB-A cables. 3.3V is coming from a variable power supply with 1A of current.

I have set the data rate to RF24_1MBPS and it didn't change anything.

Running Robin's code results in a bunch of messages of "Data received \n".
The data received is just an empty string though.

I am not sure what the issue could be. I am going to try to replace my 4 x 2 Dupont connector and see if that fixes it. Any suggestions?

It looks like the power is not a problem.

If all you see is “Data received” repeating much more quickly than data is being sent, then there is a problem - most likely the Arduino is not communicating properly with its nRF24. Run the CheckConnection.ino sketch and copy and post the serial monitor output. That will verify the wiring.

Hello and thank you for the speedy response. Running CheckConnection.ino yields the output below.

CheckConnection Starting

FIRST WITH THE DEFAULT ADDRESSES after power on
  Note that RF24 does NOT reset when Arduino resets - only when power is removed
  If the numbers are mostly 0x00 or 0xff it means that the Arduino is not
     communicating with the nRF24

SPI Speedz	= 10 Mhz
STATUS		= 0xff RX_DR=1 TX_DS=1 MAX_RT=1 RX_P_NO=7 TX_FULL=1
RX_ADDR_P0-1	= 0xffffffffff 0xffffffffff
RX_ADDR_P2-5	= 0xff 0xff 0xff 0xff
TX_ADDR		= 0xffffffffff
RX_PW_P0-6	= 0xff 0xff 0xff 0xff 0xff 0xff
EN_AA		= 0xff
EN_RXADDR	= 0xff
RF_CH		= 0xff
RF_SETUP	= 0xff
CONFIG		= 0xff
DYNPD/FEATURE	= 0xff 0xff
Data Rate	= 1 MBPS
Model		= nRF24L01+
CRC Length	= 16 bits
PA Power	= PA_MAX
ARC		= 15


AND NOW WITH ADDRESS AAAxR  0x41 41 41 78 52   ON P1
 and 250KBPS data rate

SPI Speedz	= 10 Mhz
STATUS		= 0xff RX_DR=1 TX_DS=1 MAX_RT=1 RX_P_NO=7 TX_FULL=1
RX_ADDR_P0-1	= 0xffffffffff 0xffffffffff
RX_ADDR_P2-5	= 0xff 0xff 0xff 0xff
TX_ADDR		= 0xffffffffff
RX_PW_P0-6	= 0xff 0xff 0xff 0xff 0xff 0xff
EN_AA		= 0xff
EN_RXADDR	= 0xff
RF_CH		= 0xff
RF_SETUP	= 0xff
CONFIG		= 0xff
DYNPD/FEATURE	= 0xff 0xff
Data Rate	= 1 MBPS
Model		= nRF24L01+
CRC Length	= 16 bits
PA Power	= PA_MAX
ARC		= 15

It appears the Arduino is not communicating with the NRF module. How would I go about fixing this problem? What sources of information should I use to trouble shoot the NRF24L01 module for future reference? Thanks again!

How long are the wires?

Post clear photos of your wiring. Another set or two of eyes may spots something that you are missing.

Replace the jumper wires. Use your DMM to check the wires for continuity before using them.

Did you try the:
Also for some clones, change TMRh20's RF24.cpp line 44 line 47 (in newer library version).

_SPI.setClockDivider(SPI_CLOCK_DIV2);
Into
_SPI.setClockDivider(SPI_CLOCK_DIV4);

Wires are about 8" long. I switched the second Arduino to an uno to check if my nanos were faulty. Both Nano and Uno give the same output when running CheckConnection.ino .

Yes I changed the line 47 in RF24.cpp.


I can't tell from the photos, is the 3.3V rf24 module's power supply ground (-) connected to the Arduino ground as well as the rf24 module ground? They must be.

Yes, power supply ground is connected to both Arduino microcontroller grounds and both RF24 modules.

I am not sure what else to troubleshoot. I went through the common problems page and it did not help my specific problem. I am very confused as what this could be.

It seems like this library I am using isn't working correctly with my Arduino and RF24 module. What do you recommend?

The RF24 library and the code in Robin2's tutorial have been proven good over and over. That is what I used to get my radio modules to work and what I use as the basis for all of my rf24 projects.

There are bad modules out there. I bought some myself a while back (from EBay). We have seen others that could not get them to work, but as soon as they got some from a more reputable dealer the radios worked. From where did you buy them?

An alternative to the RF24 modules are the HC12 433MHz modules. Similar range and arguably easier to use (fewer pins). I bought a pair but have not had time or reason to experiment with them.

I solved at least one issue. Turns out one of the wires on the Dupont connector was faulty. I am buying some adapter boards to mitigate this problem. Check connection now yields the below. Does this look correct?

CheckConnection Starting

FIRST WITH THE DEFAULT ADDRESSES after power on
  Note that RF24 does NOT reset when Arduino resets - only when power is removed
  If the numbers are mostly 0x00 or 0xff it means that the Arduino is not
     communicating with the nRF24

SPI Speedz	= 10 Mhz
STATUS		= 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1	= 0xe7e7e7e7e7 0x0000000000
RX_ADDR_P2-5	= 0xc3 0xc4 0x1c 0x38
TX_ADDR		= 0x0000000000
RX_PW_P0-6	= 0x06 0x00 0x00 0x00 0x00 0x00
EN_AA		= 0x3d
EN_RXADDR	= 0x03
RF_CH		= 0x02
RF_SETUP	= 0x07
CONFIG		= 0x02
DYNPD/FEATURE	= 0x00 0x00
Data Rate	= 1 MBPS
Model		= nRF24L01+
CRC Length	= Disabled
PA Power	= PA_MAX
ARC		= 0


AND NOW WITH ADDRESS AAAxR  0x41 41 41 78 52   ON P1
 and 250KBPS data rate

SPI Speedz	= 10 Mhz
STATUS		= 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1	= 0xe7e7e7e7e7 0x000000000e
RX_ADDR_P2-5	= 0x00 0xc4 0xc0 0x1c
TX_ADDR		= 0x000000000c
RX_PW_P0-6	= 0x00 0x38 0x00 0x70 0x04 0x00
EN_AA		= 0x00
EN_RXADDR	= 0x03
RF_CH		= 0x0e
RF_SETUP	= 0x27
CONFIG		= 0x02
DYNPD/FEATURE	= 0x00 0x00
Data Rate	= 250 KBPS
Model		= nRF24L01+
CRC Length	= 8 bits
PA Power	= PA_MAX
ARC		= 0

No.

Pipe addresses of zero are not recommended and used.

Is not used, besides very special circumstances, like packet sniffing.

Hello,
Could someone please share the link of where to find the "checkConnection.ino' sketch? Thanks a lot in advance.
Best,
Peter

The link in message #6, above, takes you right to it.

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