NRF24L01: Transfers fail, receiver fills terminal with blank space

Hi. I've been trying to get a pair of Arduino Pro Micros to talk to each other using NRF24L01+PA+LNA modules.

I'm using code from a tutorial I found online.

##Transmitter code:

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

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

const byte address[6] = "00001";
bool rslt;

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

void loop() {
  const char text[] = "Hello World";
  rslt = radio.write(&text, sizeof(text));
  if(rslt) {
    Serial.println("Acknowledge received");
  }
  else {
    Serial.println("Tx failed");
  }
  delay(1000);
}

##Receiver code:

#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);  }
}

On the transmitter end, I get one output of "Tx Failed" every second, and meanwhile, the receiver end spits out a rapid stream of empty received messages.

Since I was curious, I took a look at the signals with an oscilloscope, and this is roughly what I get each time:

There are some things about it that look weird to me, but since I've never used these before I'm not sure whether what I'm seeing is normal or not, especially on the CE and CSN lines.

I feel like I have tried everything at this point. I've taken the circuits apart and rebuilt them, I've switched out both of the NRF24 modules, I've switched the arduinos with spares I have, and still I end up with the same results.

##Some things about the circuit:

I'm using this (3.3V Voltage Regulator 950mA LD1117V33 (LD33V)) voltage regulator to get the 3.3V for the transceivers. There's one on each circuit. The voltage regulators get power from the VCC pin on the Arduino Pro Micro. I am also using a 10 microfarad decoupling capacitor on the 3.3V line to ground.

The pins I'm using from the Arduinos are as follows:

16 --> COPI (MOSI)
14 --> CIPO (MISO)
15 --> SCK
7 --> CE
8 --> CSN

I've read almost every forum post I could find on the NRF24L01 modules, and none of their solutions seemed to apply to me.

Any guidance on what could be going wrong is welcome!

const char text[32] = "Hello World";

This points to a not working bus connection to the RX NRF,
that would explain the failing TX also.

So does that imply that there's something wrong with my arduino on the RX side? Or is there a possibility it's something related to software?

Bad connections, bad breadboard contacts, broken wires would be my first guess.
A bad module is always possible too.

The code seems to be ok, the power supply should be sufficient.

I've checked all the connections for continuity, and I've also tested the SPI capabilities of the Arduino on its own. As far as I can tell, it's not a physical issue with the circuit, and there's nothing wrong with the SPI module on the chip.

I've also tried putting the code on an Arduino Uno (changing the pins so that they line up with the Uno's SPI pins) and I get the same sort of results. The SPI lines just aren't transmitting any data, even when the Arduino isn't wired up to anything.

All I can think is that I'm either using the library wrong, or there's something wrong with the library's interactions with my arduinos.

My list of troubleshooting tips:

If you read and, closely, follow Robin2's simple rf24 tutorial you should be able to get them working. That tutorial sure helped me. The code in the examples has been proven to work many many times. If it does not work for you, there is likely a hardware problem.

Run the CheckConnection.ino (look in reply #30 in the tutorial) to verify the physical wiring between the radio module and its processor (Arduino).

Make sure the rf24 power supply can provide enough current. This is especially true for the high power (external antenna) modules. I use homemade adapters like these. They are powered by 5V and have a 3.3V regulator on the board. Robin2 also has suggested trying with a 2 AA cell battery pack.

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 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.

UPDATE:

I got it to work. Kind of. After almost a week straight of testing connections, tweaking code, and reading through forum posts, I cracked down and bought new arduinos and new NRF24L01 boards. I suspect that there were problems with both of the parts I was using.

After some testing, I figured out that there was something going wrong with the SPI on the Arduino Pro Micros I was using. I tested code where one of the arduinos would act as the controller (master) and one of them would act as the peripheral (slave) and I was unable to get the peripheral device to actually read any data sent over SPI. The code worked just fine when I switched out the peripheral Pro Micro for an official Arduino Uno. (this would line up with what @Whandall said about a failing bus connection to the receiving NRF24L01)

That said, I still couldn't get the transmitter/receivers to work even after I tried the code with two Arduino Unos instead of the Pro Micros. I think I might have had them too close together, since they are the +PA+LNA variants with the big antennas, but I also don't have a reliable way to test them with more distance since they're just plugged into my computer. I'm not saying that they're broken, but I'm not ruling it out either until I figure out a better way to test them.

TL;DR it was a hardware problem, although I'm not sure if it was both the microcontrollers and the transmitters, or just the microcontrollers. I'm now using NRF24L01 boards from Sparkfun without the antenna add-ons, and I'm using official Arduino Micros, and the code works now.

Thanks to everyone who helped, your suggestions are much appreciated!

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