6

I am testing communication between two nRF24L01 modules. The receiver is getting the transmitted message but is also continuously reading (null) data from a closed pipe? I am using the RF24 by TMRh20 version 1.3.12 library on an Arduino Pro Mini with some modified example code. Has anyone else experienced this phenomenon or have any fix for the issue?

Transmitter:

/*
* Arduino Wireless Communication Tutorial
*     Example 1 - Transmitter Code
*                
* by Dejan Nedelkovski, www.HowToMechatronics.com
* 
* Library: TMRh20/RF24, https://github.com/tmrh20/RF24/
*/
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <printf.h>
RF24 radio(9, 10); // CE, CSN
const byte address[6] = "00001";
void setup() {
  Serial.begin(9600);
  printf_begin();
  while (!Serial);
  Serial.println("[radioSend]");
  if (radio.begin()) {
    Serial.println("Radio Receiver starting");
  } else {
    Serial.println("Radio Receiver start failed");
    while (1);
  }
  radio.setChannel(120);
  radio.openWritingPipe(address);
  radio.setPALevel(RF24_PA_MIN);
  radio.stopListening();
  radio.printPrettyDetails();
}
void loop() {
  const char text[] = "Hello World";
  radio.write(&text, sizeof(text));
  delay(10000);
}

Receiver:

/*
* Arduino Wireless Communication Tutorial
*       Example 1 - Receiver Code
*                
* by Dejan Nedelkovski, www.HowToMechatronics.com
* 
* Library: TMRh20/RF24, https://github.com/tmrh20/RF24/
*/
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <printf.h>
RF24 radio(9, 10); // CE, CSN
const byte address[6] = "00001";
long counter = 0;
void setup() {
  Serial.begin(9600);
  printf_begin();
  while (!Serial);
  Serial.println("[radioReceive]");
  if (radio.begin()) {
    Serial.println("Radio Receiver starting");
  } else {
    Serial.println("Radio Receiver start failed");
    while (1);
  }
  radio.setChannel(120);
  radio.openReadingPipe(0, address);
  radio.setPALevel(RF24_PA_MIN);
  radio.startListening();
  radio.printPrettyDetails();
}
int dpls3;
char text3[32] = "";
void loop() {
  uint8_t pipeNum;
  if (radio.available(&pipeNum)) {
    int dpls = radio.getDynamicPayloadSize();
    char text[32] = "";
    radio.read(&text, sizeof(text));
    if (pipeNum != 3) {
      Serial.print("[Pipe=");
      Serial.print(pipeNum);
      Serial.print("|Size=");
      Serial.print(dpls);
      Serial.print("|");
      Serial.print(text);
      Serial.print("] [Pipe=3|Size=");
      Serial.print(dpls3);
      Serial.print("|");
      Serial.print(text3);
      Serial.print("|Count=");
      Serial.print(counter);
      Serial.println("]");
    } else {
      memcpy(&text3, &text, 32);
      counter += 1;
      dpls3 = dpls;
    }
  }
}

Transmitter output:

[radioSend]
Radio Receiver starting
SPI Frequency       = 10 Mhz
Channel         = 120 (~ 2520 MHz)
RF Data Rate        = 1 MBPS
RF Power Amplifier  = PA_MIN
RF Low Noise Amplifier  = Enabled
CRC Length      = 16 bits
Address Length      = 5 bytes
Static Payload Length   = 32 bytes
Auto Retry Delay    = 1500 microseconds
Auto Retry Attempts = 15 maximum
Packets lost on
    current channel = 0
Retry attempts made for
    last transmission   = 0
Multicast       = Disabled
Custom ACK Payload  = Disabled
Dynamic Payloads    = Disabled
Auto Acknowledgment = Enabled
Primary Mode        = TX
TX address      = 0x3130303030
pipe 0 ( open ) bound   = 0x3130303030
pipe 1 ( open ) bound   = 0xc2c2c2c2c2
pipe 2 (closed) bound   = 0xc3
pipe 3 (closed) bound   = 0xc4
pipe 4 (closed) bound   = 0xc5
pipe 5 (closed) bound   = 0xc6

Receiver output:

[radioReceive]
Radio Receiver starting
SPI Frequency       = 10 Mhz
Channel         = 120 (~ 2520 MHz)
RF Data Rate        = 1 MBPS
RF Power Amplifier  = PA_MIN
RF Low Noise Amplifier  = Disabled
CRC Length      = 16 bits
Address Length      = 3 bytes
Static Payload Length   = 32 bytes
Auto Retry Delay    = 250 microseconds
Auto Retry Attempts = 15 maximum
Packets lost on
    current channel = 0
Retry attempts made for
    last transmission   = 0
Multicast       = Disabled
Custom ACK Payload  = Disabled
Dynamic Payloads    = Disabled
Auto Acknowledgment = 0b011111
Primary Mode        = RX
TX address      = 0x1010101010
pipe 0 ( open ) bound   = 0x1010101010
pipe 1 (closed) bound   = 0x2020270610
pipe 2 (closed) bound   = 0xc1
pipe 3 (closed) bound   = 0xc0
pipe 4 (closed) bound   = 0xc0
pipe 5 (closed) bound   = 0xc2
[Pipe=0|Size=32|Hello World] [Pipe=3|Size=0||Count=195500]
[Pipe=0|Size=32|Hello World] [Pipe=3|Size=0||Count=216665]
[Pipe=0|Size=32|Hello World] [Pipe=3|Size=0||Count=835055]
[Pipe=0|Size=32|Hello World] [Pipe=3|Size=0||Count=882618]
[Pipe=0|Size=32|Hello World] [Pipe=3|Size=0||Count=1168025]
[Pipe=0|Size=32|Hello World] [Pipe=3|Size=0||Count=1310725]
[Pipe=0|Size=32|Hello World] [Pipe=3|Size=0||Count=1405856]
[Pipe=0|Size=32|Hello World] [Pipe=3|Size=0||Count=1500987]
6
  • what is the issue specifically?
    – jsotola
    Commented Sep 4, 2021 at 16:40
  • did you write the code?
    – jsotola
    Commented Sep 4, 2021 at 16:48
  • @jsotola Did you actually read the title? The program is doing what it is supposed to do, sure but the nRF24L01 is not. If you look at the last few lines of the receiver output you will see that there is an extremely high number of null messages on pipe 3 being read on a closed pipe but not cleared. I modified the original code to show the problem. If I had just printed what was read then there would have been thousands of blank lines interspersed with the occasional "Hello World". I do not want my code to waste time handling this "hardware" issue.
    – PyNZ
    Commented Sep 4, 2021 at 20:53
  • 1
    I think someone else is having the same issue here as I was able to find a fix by ignoring any data available on pipes above 1. arduino.stackexchange.com/questions/51741/trouble-with-nrf24l01/…
    – PyNZ
    Commented Sep 4, 2021 at 21:33
  • 1
    Another example where I tested and demonstrate a fix for this issue: arduino.stackexchange.com/questions/65249/…
    – PyNZ
    Commented Sep 5, 2021 at 1:23

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.