Radio.available true even if NRF24 disconnected

Hi,

I've seen this is a common issue, but I can't find any solutions to my problem in the existing posts. I'm trying to send 'Hello World' from an Arduino Uno to an Arduino Nano through 2 NRF24L01 modules. Especially, I'm using this code for the receiver :

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

#define pinCE   7             // On associe la broche "CE" du NRF24L01 à la sortie digitale D7 de l'arduino
#define pinCSN  8             // On associe la broche "CSN" du NRF24L01 à la sortie digitale D8 de l'arduino
#define tunnel  "PIPE1"       // On définit le "nom de tunnel" (5 caractères) à travers lequel on va recevoir les données de l'émetteur

RF24 radio(pinCE, pinCSN);    // Instanciation du NRF24L01

const byte adresse[6] = tunnel;       // Mise au format "byte array" du nom du tunnel
char message[32];                     // Avec cette librairie, on est "limité" à 32 caractères par message

void setup() {
  // Initialisation du port série (pour afficher les infos reçues, sur le "Moniteur Série" de l'IDE Arduino)
  Serial.begin(9600);
  Serial.println("Récepteur NRF24L01");
  Serial.println("");

  // Partie NRF24
  radio.begin();                      // Initialisation du module NRF24
  radio.openReadingPipe(0, adresse);  // Ouverture du tunnel en LECTURE, avec le "nom" qu'on lui a donné
  radio.setPALevel(RF24_PA_MIN);  
  radio.setAutoAck(false); 
  
}

void loop() {
    radio.startListening();             // Démarrage de l'écoute du NRF24 (signifiant qu'on va recevoir, et non émettre quoi que ce soit, ici)
  
    if (radio.available()) {
    radio.read(message, sizeof(message));                        // Si un message vient d'arriver, on le charge dans la variable "message"
    Serial.print("Message reçu : "); 
    Serial.println(message);   
    delay(1000);                                              // … et on l'affiche sur le port série !
}
  else {
    Serial.println("None");
    }
}

Code which I take from a tutorial (and therefore should work). However, the serial monitor behaves as if radio.available() was always true. I mean, it behaves even if the transmitting code has never been uploaded on the transceiver arduino. It also works this way even if the receiving NRF24LO1 has no electricity inuput.
I use the correct voltage for the NRF24 and have already set up a 100uF capacitor. The setAutoAck was added after one of the existing posts, but changes nothing. I also trie to insert the startlistening inside the loop rather than in the setup, but it didn't change anything.

Can someone help me ?
Thank you

Thank you

If the wiring is correct and the code is correct then the issue is almost certainly related to power. This is especially the case with the NRF24L01 modules which include an additional amplifier chip and antenna. In a very few cases, the issue is unpredictable behavior of some clones or fakes.

Say more about how the misbehaving device is powered.

Hi,
The NRF24L01 has been tested with the 3.3V plug of my Arduino Uno, which is itself powered by my PC. I tried to use a 100uF capacitor but it made no difference. Tell me if you think an other information would be relevant.
I use the black version of the NRF24LO1, without external antenna.

As I said, the issue stays even if the module is not powered.

Try a simple test such as that in post #2 here and read the accompanying text :

These adapters appear to deliver reliable results when the problem is related to power:

image

Yes. An NRF24L01, when completely disconnected, will still deliver "ghost" radio.available() == true results. That is the way the standard library works.

Thanks for the adapter reference. I already ordered a bunch of those but they're not arrived yet.

The code in post #2 of this topic outputs that :

Data received 
Data received 
Data received 
Data received 
Data received 
Data received 
Data received 
Data received 
Data received 
Data received 
Data received 
Data received ⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮z


There were more "Data received" before. That was the second try. On the first try, it just wrote "Data received" again and again.

Thank you,

I guess your connections are bad (like broken, missing or misplaced wires),
or the NRF is nonfunctional (like killed with 5V supply).

100 uF is too big, a value between 1 and 10 uF works well from my experience.

Setting pin 10 to OUTPUT could also help the SPI library to act as master.

If you just want to check the connections, try this stand alone register print program, it makes no attempt to transmit or receive, so should not have supply issues, no library needed.

/*******************************************************************************************************
  Programs for Arduino - Copyright of the author Stuart Robinson - 05/12/20

  This program is supplied as is, it is up to the user of the program to decide if the program is
  suitable for the intended purpose and free from errors.
*******************************************************************************************************/

/*******************************************************************************************************
  Program Operation - This program is stand alone, it is not necessary to install a NRF2401 library.
  The program checks that the NRF2401 can be written to and read from over the SPI bus.

  The contents of the NRF2401 registers from 0x00 to 0x19 are read and printed to the serial monitor.
  If the connections are OK then the printout should look like this;

  57A_NRF24L01_Is_It_There ?

  Print registers 0x00 to 0x1F
  Reg    0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F
  0x00  00 3F 02 03 5F 4C 27 42 00 00 E7 52 C3 C4 C5 C6
  0x10  E7 00 20 00 00 00 00 12 00 00

  If you get this output;

  Print registers 0x00 to 0x1F
  Reg    0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F
  0x00  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10  00 00 00 00 00 00 00 00 00 00

  Then the CSN_PIN is not connected or defined correctly.

  Note that this is just a 'is it there' type check, the CE pin is not used or needed for this simple check.
  If the device is faulty, not present or wired incorrectly the register contents will likely be all 00s or
  FFs. The program makes no attempt to turn on the RF transmitter or receiver.

  Serial monitor baud rate is set at 9600.
*******************************************************************************************************/

#include <SPI.h>

#define CSN_PIN 10
#define CMD_R_REGISTER      0x00
#define CMD_W_REGISTER      0x20


void loop()
{
  Serial.println(F("Print registers 0x00 to 0x19"));
  printRegisters(0, 0x19);
  Serial.println();
  delay(5000);
}


void printRegisters(uint16_t Start, uint16_t End)
{
  uint16_t Loopv1, Loopv2, endLoopv2, RegCount, RegData;

  RegCount = End - Start + 1;
  Serial.print(F("Printing "));
  Serial.print(RegCount);
  Serial.println(F(" registers"));
  Serial.println();

  Serial.print(F("Reg    0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F"));
  Serial.println();

  for (Loopv1 = Start; Loopv1 <= End;)           //32 lines
  {
    Serial.print(F("0x"));
    if (Loopv1 < 0x10)
    {
      Serial.print(F("0"));
    }
    Serial.print((Loopv1), HEX);                 //print the register number
    Serial.print(F("  "));

    if (RegCount < 16)
    {
      endLoopv2 = RegCount - 1;
    }
    else
    {
      endLoopv2 = 15;
    }

    for (Loopv2 = 0; Loopv2 <= endLoopv2; Loopv2++)
    {
      RegData = readRegister(Loopv1);
      RegCount--;

      if (RegData < 0x10)
      {
        Serial.print(F("0"));
      }
      Serial.print(RegData, HEX);                //print the register number
      Serial.print(F(" "));
      Loopv1++;
    }
    Serial.println();
  }
}


uint8_t readRegister(uint8_t reg)
{
  uint8_t result;

  digitalWrite(CSN_PIN, LOW);
  SPI.transfer(CMD_R_REGISTER | reg);
  result = SPI.transfer(0xff);
  digitalWrite(CSN_PIN, HIGH);
  return result;
}


void setup()
{
  Serial.begin(9600);
  pinMode(CSN_PIN, OUTPUT);
  Serial.println();
  Serial.println(F("57A_NRF24L01_Is_It_There ?"));
  Serial.println();
  SPI.begin();
}

Hi,
Thanks for such a code.
Just tried it and had 00 everywhere. I tried to switch the CE and CSN wires (I think they were correctly wired but it was seemingly wrong) and then got a mix of 00 and FF. I changed the chip and just got that output :

Reg    0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F
0x00  00 00 00 00 00 00 00 00 00 00 00 00 00 60 00 00 
0x10  00 00 00 00 00 00 00 00 80 00 

Print registers 0x00 to 0x19
Printing 26 registers

Reg    0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F
0x00  00 00 00 00 00 00 00 00 00 00 E7 00 00 00 00 00 
0x10  00 00 00 00 00 00 00 00 00 00 


It's not really a mistake full 00 but it's not really what we are expecting I guess. How should I undestand this ?

After a power on, my NRF24L01+ on a Nano gives


57A_NRF24L01_Is_It_There ?

Print registers 0x00 to 0x19
Printing 26 registers

Reg    0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F
0x00  10 3F 03 03 03 02 0F 0E 00 00 E7 C2 C3 C4 C5 C6 
0x10  E7 00 00 00 00 00 00 11 00 00

Print registers 0x00 to 0x19
Printing 26 registers

Reg    0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F
0x00  08 3F 03 03 03 02 0F 0E 00 00 E7 C2 C3 C4 C5 C6 
0x10  E7 00 00 00 00 00 00 11 00 00 

The last values repeat over and over.

Well that simple code does work on a UNO, so logically some of the following are true;

The NRF24L01 are faulty.
You have the wiring wrong or its faulty.
The UNO is faulty.

The UNO works, I've already used it and the problem also comes on my Nano.
I checked the wiring and changed once the wires.
After changing the NRF to a chip I had not used before, I have this :

Print registers 0x00 to 0x19
Printing 26 registers

Reg    0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F
0x00  08 08 00 00 00 02 02 02 02 00 00 00 C3 C3 C3 FF 
0x10  E7 E7 E7 FF FF 00 00 00 00 00 

Print registers 0x00 to 0x19
Printing 26 registers

Reg    0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F
0x00  00 00 00 03 03 03 00 00 00 00 00 00 00 00 00 C6 
0x10  00 00 00 00 00 00 00 00 00 00 

The values change with time. I guess it is still wrong ?

What do you use with your Nano to plug the NRF ? I think the card is giving a 5V power ?

Depending on the Nano / clone, the 3.3volts may be derived from the USB interface chip (say 50mA). This appears to be unsuitable for reliable operation of the NRF24L01 and provides power only if the Nano is powered via a USB cable.

Using the 5 chips I own, I always have the same kind of results. I'm so lost :confused: . I tried with and without a capacitor, I tried with a Uno and a Nano, I checked the wiring several times. What's left ?

Thank you so much for your continuous support, you're so kind (and saving my graduation by the way :grinning:)

P.S. : the NRFs are from AZDelivery, I have not seen anything saying they're not reliable.

Unfortunatly there does appear to be a fair few dodgy NRF24s out there.

When I went through the pile I had aquired, maybe 10 or more, around 50% of them would not work.

The reason behind the register test program I posted is that its the most basic of programs possible for communicating with the NRF24. The program does not transmit or receive so all the 3.3V supply has to manage is circa 500uA.

What's weird is that when I uncorrectly plug the NRF on the Arduino I have only 00. But when I plug it correctly, i have those weird outputs I sent earlier.


Reg    0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F
0x00  00 00 00 03 03 03 00 00 00 00 00 00 00 00 00 C6 
0x10  FF FF FF 00 00 00 00 00 00 00 

Print registers 0x00 to 0x19
Printing 26 registers

Reg    0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F
0x00  08 08 08 00 00 00 0F 0F 0F 0F 00 00 00 C4 C4 C4 
0x10  80 00 00 00 00 00 00 11 11 11 

Therefore the chip isn't totally broken I guess, otherwise I would have only 00 ?!?

Which "Arduino" are you talking about now? You've mentioned a Uno and a Nano.
Plugging it "correctly" is usually a good idea.

Have you tried reversing the roles of the Arduinos so that the receiver, the one giving the incorrect radio.available() results, is the Uno ?

I'm talking about the Uno now.

At the beginning, the receiver was the Nano (and I had this issue). I, then, switched to the Uno when I saw the testing code from srnet to have a proper 3.3V power source. The problem remained.

That's why I'm really doubtful that 2 Arduinos and 5 NRF are all faulty.

The problem with support issues like this, is working out what is not being done correctly.

Start from the assumption that the software libraries and tutorials that have been around for a good few years do actually work and are reliable.

Then assume that if they dont work for you, its not that the libraries or tutorials are defective or need some form of 'adjustment' to work correctly with your hardware.

These NRF24L01 devices: ?

And you have used this pinpout (viewed from the top) ? :
image