NRF24L01 Not Working

I'm using 2 R4 Minimas to have a distance sensor on one Arduino to tell the other one when to move a servo and motor. I have no idea if the NRFs are broken or my code or what.
I even tried using a script to check if it is working or not, and it doesn't even print anything to the Serial Monitor.

I just found that when I power up the receiver side (motor and servo) I am getting random values from the transmitter (distance sensor) and it has no power.

This is the NRF checker code:

#include <RF24.h>
#include <RF24_config.h>
#include <nRF24L01.h>
#include <printf.h>

/*
  If your serial output has these values same then Your nrf24l01 module is in working condition :
  
  EN_AA          = 0x3f
  EN_RXADDR      = 0x02
  RF_CH          = 0x4c
  RF_SETUP       = 0x03
  CONFIG         = 0x0f
  
  This code is under public domain
  
  Last updated on 21/08/28 
  https://dhirajkushwaha.com/elekkrypt
 */

#include <SPI.h>


RF24 radio(7, 8);

byte addresses[][6] = {"1Node", "2Node"};


void setup() {
  radio.begin();
  radio.setPALevel(RF24_PA_LOW);
  
  radio.openWritingPipe(addresses[0]);
  radio.openReadingPipe(1, addresses[1]); 
  radio.startListening();
  
  Serial.begin(9600);
  printf_begin();

  radio.printDetails();
  
}

void loop() {
//  empty

}

Distance Sensor (Transmitter):

#include <RF24.h>
#include <RF24_config.h>
#include <nRF24L01.h>
#include <printf.h>
#include <SPI.h>
#include "SR04.h"
#define TRIG_PIN 3
#define ECHO_PIN 2

RF24 radio(7,8);

const byte address[6] = "00001";

int MoveDoor = 0;


SR04 sr04 = SR04(ECHO_PIN,TRIG_PIN);
long a;
int myLength = 10;

void setup() 
{
  Serial.begin(9600);

  radio.begin();
  radio.setChannel(0x55);
  radio.openWritingPipe(0xF0F0F0F0AA);
  radio.setPALevel(RF24_PA_MIN);
  radio.stopListening();
  radio.powerUp();
}

void loop() 
{
  a=sr04.Distance();
  Serial.print(a);
  Serial.print("\n");
  radio.write(&a,sizeof(a));
  delay(1000);
}

Servo and Motor (Reciever):

#include <RF24.h>
#include <RF24_config.h>
#include <nRF24L01.h>
#include <printf.h>

#include <SPI.h>

#include <Servo.h>

RF24 radio(7, 8);

const byte address[6] = "00001";

const int MPinA = 3;
const int MPinB = 2;

const int ServoUp = 70;
const int ServoDown = 0;

unsigned long startMillis;
unsigned long currentMillis;
const unsigned long time = 5000;

bool MovingDoor = false;

int Temp = 0;

Servo servo;

void MoveDoor()
{
  MovingDoor = true;
  while(MovingDoor)
  {
    currentMillis = millis();
    if(currentMillis-startMillis >= time)
    {
      servo.write(ServoUp);
      digitalWrite(MPinA,LOW);
      digitalWrite(MPinB,LOW);
      MovingDoor = false;
    }
    else
    {
      servo.write(ServoDown);
      digitalWrite(MPinA,HIGH);
      digitalWrite(MPinB,LOW);
    }
  }
}

void setup() 
{
  pinMode(MPinA,OUTPUT);
  pinMode(MPinB,OUTPUT);

  servo.attach(6);
  servo.write(70);

  radio.begin();
  radio.setChannel(0x55);
  radio.openReadingPipe(0,0xF0F0F0F0AA);
  radio.setPALevel(RF24_PA_MIN);
  radio.startListening();
  radio.powerUp();
}

void loop() 
{
  if(radio.available())
  {
    long a = 0;
    radio.read(&a,sizeof(a));
    Serial.print(a);
    Serial.print("\n");
  }
}

Can someone please help?
Thank you so much!

Before posting your schematic, please review the forum Additionally, include links to the technical information for your hardware and provide a preliminary schematic that shows all power, ground, and power sources.

For more guidance, please refer to this link:

Important Notes:

  • Breadboard diagrams (often referred to as "frizzes") are not considered proper schematics in this context.
  • Wiring diagrams are helpful for assembly but are not effective for debugging.
  • Screenshots are discouraged because they are often hard to read. Please provide high-quality schematics.

Providing the correct information will help others understand your setup and offer better assistance.

This is how I connected each NRF to the arduino

Good start with the Schematic but there are a few issues that are making it harder to read, such as:

  • Lines crossing over each other or connecting at unclear points.
  • Lack of squared or spaced-out connections, which could help make it more organized.
  • Missing power source(s), which are essential for understanding the full circuit.

To improve the schematic, I suggest:

  1. Separating or rerouting crossing lines to reduce confusion about which lines are connected.
  2. Squaring off connections rather than having diagonal or curved lines, as this generally makes schematics cleaner and easier to follow.
  3. Adding clear labels for power sources (e.g., Vcc, GND, etc.), which is crucial for understanding how the components are powered.

Power Stability Issues with RF24 Radio Modules

As described in the RF24 Common Issues Guide, radio modules, especially the PA+LNA versions, are highly reliant on a stable power source. The 3.3V output from Arduino is not stable enough for these modules in many applications. While they may work with an inadequate power supply, you may experience lost packets or reduced reception compared to modules powered by a more stable source.

Symptoms of Power Issues:

  • Radio module performance may improve when touched, indicating power stability issues.
  • These issues are often caused by the absence of a capacitor, a common cost-saving omission by some manufacturers.

Temporary Patch :

  • Add Capacitors: Place capacitors close to the VCC and GND pins of the radio module. A 10uF capacitor is usually sufficient, but the exact value can depend on your circuit layout.
  • Use Low ESR Capacitors: Capacitors with low Equivalent Series Resistance (ESR) are recommended, as they provide better power stability and performance.

Adding the appropriate capacitors can greatly improve the reliability of your RF24 module by ensuring a stable power supply, thus minimizing packet loss and enhancing overall performance. A separate power supply for the radios is the best solution.

Is this better? And how would I fix the power issue?

Try the sample code in post #2 of the following thread to check the basic function of your NRF24L01 modules (without servo, distance sensor etc. connected).

If that fails, use the code in post #30 of that thread to generate diagnostic output from a connected NRF24L01 module. Post the output so someone can check it.

The most common problem with these modules appears to be an inadequate power supply as already mentioned by @gilshultz .

You've labelled the board as a Uno Rev. 3 in the schematic but said in the text that you are using R4 Minimas boards. The difference here is important because you have mixed long and int data types between the transmitter and the receiver and this mixture works only on a 32 bit MCU.

Hi, @ace595

Have you checked if the libraries are compatible with the UNO R4 Minima.

Arduino UNO R4 Minima! This board boasts the RA4M1 microprocessor from Renesas,

Can you please post a copy of your circuit, a picture of a hand drawn circuit in jpg, png?
Hand drawn and photographed is perfectly acceptable.
Please include ALL hardware, power supplies, component names and pin labels.

Thanks.. Tom.. :smiley: :+1: :coffee: :australia:

1 Like

The SimpleRx program kept printing "Data received" while the SimpleTx program kept printing, "Data Sent Message 0 Tx failed."
What does this mean?

It means it is not working so you should try the next activity l suggested:

I used the code on post #30 and nothing printed to the Serial Monitor.
EDIT:
I think something is up with my Minimas, when I just run a program that prints to the Serial Monitor, nothing shows up.

Hi, @ace595

Have you got the baud rate on the monitor the same as the baud rate set in the code?

Have you checked if the libraries are compatible with your controller?

Tom.... :smiley: :+1: :coffee: :australia:

I set the baud rate to 9600 on both so that is working but I dont know how to check if my libraries are compatible, but I have used the Minima before and it has worked.

Look up the library documentation

Use Google to find the documentation.

Tom.. :smiley: :+1: :coffee: :australia:

They are all compatible, and I remember testing a few NRFs with the code in the first post and it worked, so I don't know what is going on right now.

It is clear from the screenshots in post #8 that you have no difficulty printing to the serial console at least at 9600 baud.
If the following test still does not work or produce any output, ensure that compiler warnings are switched on under "preferences" in the IDE and include the text of any compiler output (not a screenshot).

I shut down and powered on my PC and the SimpleTx and Rx programs run with everything being received. But when I run my own program, the Distance sensor and servo and motor sketches in post 1, the receiver is only printing 0. Can you please help?

So, if I interpret this correctly, it appears that the radio modules are OK.

and here:

Are you seeing values other than 0 being printed by the transmitter ? Assuming you are, then start removing the servo and SR04 code until it works in an attempt to find out where the error is. If it still does not work, then use the working SimpleTx and Rx programs as a basis and start adding servo/SR04 code until these start to fail.

Incidentally, (1) don't make changes to your code in the first post. If you make any changes, put the complete changed code in a new post. This because changing the original code can render the following comments invalid.
(2) if you get any compiler warnings (after enabling these in the IDE) show what these are.

Yes, so the NRFs seem to be working fine in the Simple Tx and Rx sketches.
And I just found out if I hold the NRFs closer, the receiver starts printing random numbers.
And if I unplug all components and set the sended value to 100 rather than the distance from the sensor I still get the same thing. Even if I unplug the transmitter from power, it keeps printing zeros and random numbers.

void loop() 
{
  //a=sr04.Distance();
  Serial.print(a);
  Serial.print("\n");
  radio.write(&a,sizeof(a));
  delay(1000);
}

All plugged in:

Unplugged transmitter (I have clicked the button to clear the monitor and the values instantly pop back up):

Okay I reprogrammed the motor code using the Simple Tx and Rx programs as bases for the NRFs and it works, Thank you so much everyone!