nRF24LO1 project stopped working

I built a project using 2 x nRF24LO1 modules with adaptor and it worked fas intended, the sounder gave a variable tone and the LED went on and off. For some reason it has stopped working and I tried with two new nRF24LO1s but to no avail. I have looked through the sketches but can't find anything wrong and I have checked and checked the wiring and all appears to be well. I am tearing out what little hair I have left and would appreciate some fresh eyes to see if they can see my error(s). the Transmitter and receiver sketches are as follows:

The Receiver Sketch

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

#define relayPin A0


int buttonState = 0;
int redLED = 2;

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

// SCK - Pin 13, MOSI - Pin 11 & MISO - Pin 12

const byte address[6] = "00002";

// ISR Function

void blinkLED() {
  digitalWrite(redLED, !digitalRead(redLED));

}

// Standard setup

void setup() {
  Serial.begin(9600);
  pinMode(relayPin, OUTPUT);
  pinMode(redLED, OUTPUT);
  digitalWrite(relayPin, LOW);
  radio.begin();
  radio.openReadingPipe(0, address);
  radio.setPALevel(RF24_PA_MIN);

}

// Standard Loop

void loop() {
  radio.startListening();
  while (!radio.available());
  radio.read(&buttonState, sizeof(buttonState));
  Serial.println(buttonState);

  if (buttonState == 1) {

    for (int a=0; a<=10; a++) {
    for (int i=1000; i<=1050; i++) {

    tone(relayPin, i, 100);
    delay(10);  

      interrupts();
      Timer1.initialize(75000);
      Timer1.attachInterrupt(blinkLED);

      }
    }
  }
  
  else 
  {
    digitalWrite(relayPin, LOW);
    noInterrupts();
    digitalWrite(redLED, LOW);
  }
}

and the transmitter sketch is

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

#define buttonPin A0

int buttonState = 0;

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

// SCK - Pin 13, MOSI - Pin 11 & MISO - Pin 12

const byte address[6] = "00002";

void setup() {
  pinMode(buttonPin, INPUT_PULLUP);
  Serial.begin(9600);
  radio.begin();
  radio.openWritingPipe(address);
  radio.setPALevel(RF24_PA_MIN);
  radio.stopListening();
}
void loop() {

  buttonState = digitalRead(buttonPin);

  if (buttonState == 1)
  {
    buttonState = 0;
  }
  else if (buttonState == 0)
  {
    buttonState = 1;
  }
  
  Serial.println(buttonState);
  radio.write(&buttonState, sizeof(buttonState));
  delay(50);
}

The transmitter sketch serial monitor shows the button state, but the receiver sketch serial monitor returns -10024 constantly. Photos show both units.

in both cases the CE pin is connected to pin 7, the CSN to pin 8, the SCK to pin 13, the MO to pin 11 and the M1 to pin 12. LED is on pin 2 and the buzzer(relayPin) is on pin A0

I found a test sketch and all four modules returned the same data, namely

EN_AA 0x3f

EN_RXADDR. 0x1c

RF_CH. 0x38

RF_SETUP 0x1c

CONFIG. 0x08

Surely all four modules can't have gone faulty at the same time!

Set your IDE to verbose mode so even minor warnings are shown. Maybe there will be some useful information.

IDE >> FILE >> PREFERENCES >> SHOW VERBOSE OUTPUT DURING >> compile

It worked now it doesn't, so this seems to not be software.

Post that sketch, or the pair of sketches that you found, didn't mess with and used just to establish that your radio set was functional.

If you have no such pair, you should, for this exact circumstance.

Are your radios separated by 2 meters at least when you test them? Sometimes too close is too close.

a7

Your results are not to surprising, you are under powering the radio. Use a separate poser supply, the Arduino is NOT a power supply. This might help:
Power Stability Issues with RF24 Radio Modules

As described in the RF24 Common Issues Guide, radio modules, especially the PA+LNA versions, are highly dependent on a stable power source. The 3.3V output from an Arduino is often not stable enough for these modules in many applications. While they may appear to work with an inadequate power supply, you may experience lost packets or reduced reception compared to modules powered from a more stable source. The Nano/UNO 5V rail can also be a problem, as it may not supply enough current during transmit.

Symptoms of Power Issues:

Radio module performance may improve when touched, indicating power stability problems.

These issues are often caused by the absence of a local capacitor, a common cost-saving omission by some manufacturers.

Temporary Patch:

Add capacitors close to the VCC and GND pins of the radio module. A 10 uF 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) provide better power stability and improved performance.

Be sure the transmitter and receiver are at least one meter apart. More distance is better during testing.

Reference:

During TX (3.3V supply), worst case current depends on which module you have:

  1. Plain nRF24L01+ module (no PA/LNA, small PCB antenna)

TX current at 0 dBm (max power): typically about 11 to 12 mA.
Lower power levels are less, roughly 7 to 9 mA depending on setting.

Rule of thumb: budget at least 15 mA for the radio itself.

  1. nRF24L01+ PA+LNA long-range module (with external power amplifier, often SMA antenna)

TX current at max PA level: typically about 115 to 130 mA.
Current peaks can be higher. A safe design budget is 150 to 200 mA available at 3.3V.

Power notes:

Place local decoupling capacitors at the module: 0.1 uF ceramic plus 10 to 47 uF electrolytic or tantalum directly at VCC and GND.

For PA+LNA modules, do not rely on a weak 3.3V pin. Use a proper 3.3V regulator with adequate current capacity.

Using appropriate capacitors can greatly improve the reliability of your RF24 module by ensuring a stable power supply, minimizing packet loss, and improving overall performance. A separate regulated power supply for the radios is often the best long-term solution.

Excellent description! The problem in a lot of cases is not the average but the peak current.

@alto777 's post regarding the minimum distance is also a valuable hint. If sender and receiver are placed too close the receiver may be overdriven.

@SierraGolfMike:

You might be interested in reading this

https://wolles-elektronikkiste.de/en/nrf24l01-2-4-ghz-radio-modules

This page provides comprehensive information about the use of nrf boards.

This from the loop() in your receiver sketch seems unusual and likely to give unpredictable behaviour:

Also, which version of the NRF24L01 library are you using? There have been some recent changes:

This was the test sketch:

/*
  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
  n
 */

#include <SPI.h>
#include <RF24.h>
#include <printf.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

}

The serial monitor output for the Receiver was:

SPI Speedz	= 10 Mhz
STATUS		= 0x0e RX_DR=0 TX_DS=0 TX_DF=0 RX_PIPE=7 TX_FULL=0
RX_ADDR_P0-1	= 0x000000001c 0x0000000070
RX_ADDR_P2-5	= 0x38 0x38 0x1c 0xc6
TX_ADDR		= 0x6c6c6c6cec
RX_PW_P0-6	= 0xe0 0x1c 0xe0 0x38 0x38 0x1c
EN_AA		= 0x3f
EN_RXADDR	= 0x1c
RF_CH		= 0x38
RF_SETUP	= 0x1c
CONFIG		= 0x08
DYNPD/FEATURE	= 0x38 0x38
Data Rate	= 2 MBPS
Model		= nRF24L01+
CRC Length	= 8 bits
PA Power	= PA_HIGH
ARC		= 0

the serial monitor output from the Transmitter was:

SPI Speedz	= 10 Mhz
STATUS		= 0x0e RX_DR=0 TX_DS=0 TX_DF=0 RX_PIPE=7 TX_FULL=0
RX_ADDR_P0-1	= 0x65646f4e31 0x65646f4e32
RX_ADDR_P2-5	= 0xc3 0xc4 0xc5 0xc6
TX_ADDR		= 0x65646f4e31
RX_PW_P0-6	= 0x20 0x20 0x20 0x20 0x20 0x20
EN_AA		= 0x3f
EN_RXADDR	= 0x02
RF_CH		= 0x4c
RF_SETUP	= 0x03
CONFIG		= 0x7f
DYNPD/FEATURE	= 0x00 0x00
Data Rate	= 1 MBPS
Model		= nRF24L01+
CRC Length	= 16 bits
PA Power	= PA_LOW
ARC		= 15

I made sure the modules were 2m apart and the sketches I initially posted were the ones that worked.

It does seem odd if you used the same test sketch on both units that you get different values here:

That test was not anyway intended to transmit any data over the radio, just to test the communication between a MCU and the NRF24L01 radio unit.

Try the test code for a transmitter and receiver pair in post #2 in this thread. Simple nRF24L01+ 2.4GHz transceiver demo

As I implied before in post #7, your use of noInterrupts() is a likely culprit. This statement has wide ranging side effects. For example at least the millis() timer, SPI and Serial, which you are using, will all be affected.

Tried the test, still no joy, I then ran the sketch to test comms between nRF and Arduino and it seems to be ok in RX and TX.

One thought, when did V1.6.0 of the RF24 library come out? Is it possible that a newer version is not compatible with my nRF modules?

Rolled back to 1.4.11, no difference!

Did it ever work? The thread title implies it may have done.

Anyway, during your test with the code linked in post #9, was the led and buzzer also connected ? From the pictures, it appears:

  1. There is no current limiting resistor for the led.
  2. There is no flyback diode for the buzzer.
  3. The power should be OK because it seems that you are using 5v with a purpose designed NRF24L01 adapter which contains a voltage regulator (3v3) and appropriate capacitors.

For a simple use case such as that "Robin2" test pair which I linked the version of the NRF24L01 library should not be an issue. Focus on getting that simple test working then start adding any extras.

Yes it did work, I know there was no resistor on the LED but it did work and the LED is still fine. I did not know that I required a flyback diode on the buzzer but it was working without it. The LED and buzzer were still connected during the test.

I have stripped everything down and will try the simple test again, it initially did not work.

Thank you for your help.

This is your main clue.

It means the transmitter is talking to the radio properly, but the receiver is not.

I would double check wiring etc on the receiver end.

I stripped everything down and wired again without the module adaptors and changed from 5V to 3.3V

I loaded the SimpleTX and SimpleRX sketches as mentioned by others. and connected them up to different computers.

The serial monitor for the SimpleTX sketch reads:

Data Sent Message 0 Tx Failed about every half second

the serial monitor for the SimpleRX sketch reads:

Data Received very quickly at least two or three per second!

I would run the printDetails example again to see if you have the wiring correct.

Both sides should read similar to the Transmitter output in the example I posted.

Nothing will work until you get the microcontrollers "talking" to the radios.

Checked and verified wiring many times, ran the printDetails sketch again and everything is coming back as 0x00 on all four of my modules!!! Things are going from bad to worse! Could all my modules be goosed?

Your modules are likely fine. Its unlikely all 4 have failed. I slightly modified the code to run.

Its much more likely you have bad wires themselves lol. I've had some cheap connectors that failed right away when plugging/unplugging.

You have them connected like above?

Yes, connected as shown, I will check my cables to ensure I have good connections. Is that the modified code above?

Fiest module:

SPI Speedz	= 10 Mhz
STATUS		= 0x0e RX_DR=0 TX_DS=0 TX_DF=0 RX_PIPE=7 TX_FULL=0
RX_ADDR_P0-1	= 0x0000000070 0x0000000070
RX_ADDR_P2-5	= 0x38 0x38 0x1c 0xc6
TX_ADDR		= 0x65646f4e31
RX_PW_P0-6	= 0x20 0x1c 0x20 0x38 0x38 0x1c
EN_AA		= 0x3f
EN_RXADDR	= 0x1c
RF_CH		= 0x38
RF_SETUP	= 0x1c
CONFIG		= 0x7f
DYNPD/FEATURE	= 0x38 0x38
Data Rate	= 2 MBPS
Model		= nRF24L01+
CRC Length	= 16 bits
PA Power	= PA_HIGH
ARC		= 0

Second module:

SPI Speedz	= 10 Mhz
STATUS		= 0x0e RX_DR=0 TX_DS=0 TX_DF=0 RX_PIPE=7 TX_FULL=0
RX_ADDR_P0-1	= 0x0000000070 0x0000000070
RX_ADDR_P2-5	= 0x38 0x38 0x1c 0xc6
TX_ADDR		= 0x65646f4e31
RX_PW_P0-6	= 0x20 0x1c 0x20 0x38 0x38 0x1c
EN_AA		= 0x3f
EN_RXADDR	= 0x1c
RF_CH		= 0x38
RF_SETUP	= 0x1c
CONFIG		= 0x7f
DYNPD/FEATURE	= 0x38 0x38
Data Rate	= 2 MBPS
Model		= nRF24L01+
CRC Length	= 16 bits
PA Power	= PA_HIGH
ARC		= 0

I get these figures with the adaptor fitted and voltage at 5V