nRF24L01 TX and RX not working (I am not sure if it is hardware or software)

Hey everyone,

I hope everything is going well. Recently I bought a pack of three nRF24L01+PA+LNA+breakout boards from Amazon. I followed this tutorial and hooked the transmitter and receiver into two seperate Arduino Uno's, however nothing is working. Here is the code.

Transmitter

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(7, 8); // CE, CSN      // Define instance of RF24 object called 'radio' and define pins used
const byte address[6] = "00001";  // Define address/pipe to use.
unsigned long count = 0;                   // Use to count the number of messages sent
char countStr[10];                 // Create a char array to hold count as a string
//===============================================================================
//  Initialization
//===============================================================================
void setup() 
{
  Serial.begin(9600);
  radio.begin();                  // Start instance of the radio object
  radio.openWritingPipe(address); // Setup pipe to write data to the address that was defined
  radio.setPALevel(RF24_PA_MAX);  // Set the Power Amplified level to MAX in this case
  radio.stopListening();          // We are going to be the transmitter, so we will stop listening
}
//===============================================================================
//  Main
//===============================================================================
void loop() 
{
  count++;                              // Increment the count
  ltoa(count,countStr, 10);             // Convert the count and put into the char array.
  char text[30] = "Sending Message: ";  // Create our base message.
  strcat (text, countStr);              // Append the count to the base message
  radio.write(&text, sizeof(text));     // Write the char array.
  Serial.println("Send message");
  delay(1000);                          // Delay for 1 second, then repeat
}

Receiver

/*
 * nRF24L01 Receiver Test Software
 * 
 * Exercises the nRF24L01 Module.  This code runs on the receiver 'slave' device.
 * Use the nRF24L01_Transmitter_Test software for the transmitting 'master' device
 * 
 * This uses the RF24.h library which can be installed from the Arduino IDE
 * Pins used for the SPI interface are determined by the Arduino being used. 
 * The other two pins are arbitrary and can be changed if needed.  Redfine them in the RF24  
 * statement.  Default shown here is to use pins 7 &
 */
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(7, 8); // CE, CSN      // Define instance of RF24 object called 'radio' and define pins used
const byte address[6] = "00001";  // Define address/pipe to use. This can be any 5 alphnumeric letters/numbers
//===============================================================================
//  Initialization
//===============================================================================
void setup() {
  Serial.begin(9600);                // Start serial port to display messages on Serial Monitor Window
  radio.begin();                     // Start instance of the radio object
  radio.openReadingPipe(0, address); // Setup pipe to write data to the address that was defined
  radio.setPALevel(RF24_PA_MAX);     // Set the Power Amplified level to MAX in this case
  radio.startListening();            // We are going to be the receiver, so we need to start listening
}
//===============================================================================
//  Main
//===============================================================================
void loop() {
  if (radio.available()) {  
    char text[32] = "";               // Clear buffer
    radio.read(&text, sizeof(text));  // Read incoming message into buffer
    Serial.println(text);             // Print the message to the Serial Monitor window
  }
}

Currently, this does not work. All of the wires are hooked up correctly. What is interesting is when the receiver is plugged into the arduino's 3.3v, radio.available() is always true. However when plugged into 5v, it is always false. This is the case for all components, which makes me think either I'm doing something wrong, or all of them are faulty.


Same setup for TX and RX

These things are known sometimes to be faulty, however can someone make sure there is no problem with the code so I know for sure it is a hardware problem?

Thank you all for your time!

The adapter board needs to be powered by 5V to get the 3.3V that the rf24 needs.

Code works for me after I set the CE and CSN pins to match my boards setup (real hardware).

From receiver serial monitor

Sending Message: 14
Sending Message: 15
Sending Message: 16
Sending Message: 17
Sending Message: 18
Sending Message: 19
Sending Message: 20
Sending Message: 21
Sending Message: 22
Sending Message: 23
Sending Message: 24
Sending Message: 25

My RF24 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). This is especially useful if all you see is “Data received” repeating much more quickly then there is a problem - most likely theArduino is not communicating properly with its nRF24.

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.

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