Problem with NRF24L01 receiver with Arduino Nano

I was having some trouble with NRF communication. I followed this tutorial to set up a demo transmitter and receiver using two NRF modules.

// SimpleTx - the master or the transmitter

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


#define CE_PIN   9
#define CSN_PIN 10

const byte slaveAddress[5] = {'R','x','A','A','A'};


RF24 radio(CE_PIN, CSN_PIN); // Create a Radio

char dataToSend[10] = "Message 0";
char txNum = '0';


unsigned long currentMillis;
unsigned long prevMillis;
unsigned long txIntervalMillis = 1000; // send once per second


void setup() {

    Serial.begin(9600);

    Serial.println("SimpleTx Starting");

    radio.begin();
    radio.setDataRate( RF24_250KBPS );
    radio.setRetries(3,5); // delay, count
    radio.openWritingPipe(slaveAddress);
}

//====================

void loop() {
    currentMillis = millis();
    if (currentMillis - prevMillis >= txIntervalMillis) {
        send();
        prevMillis = millis();
    }
}

//====================

void send() {

    bool rslt;
    rslt = radio.write( &dataToSend, sizeof(dataToSend) );
        // Always use sizeof() as it gives the size as the number of bytes.
        // For example if dataToSend was an int sizeof() would correctly return 2

    Serial.print("Data Sent ");
    Serial.print(dataToSend);
    if (rslt) {
        Serial.println("  Acknowledge received");
        updateMessage();
    }
    else {
        Serial.println("  Tx failed");
    }
}

//================

void updateMessage() {
        // so you can see that new data is being sent
    txNum += 1;
    if (txNum > '9') {
        txNum = '0';
    }
    dataToSend[8] = txNum;
}

I used the code given is post #2 of the tutorial for the transmitter and the following code of the receiver.

// SimpleRx - the slave or the receiver

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

#define CE_PIN   9
#define CSN_PIN 10

const byte thisSlaveAddress[5] = {'R','x','A','A','A'};

RF24 radio(CE_PIN, CSN_PIN);

char dataReceived[10]; // this must match dataToSend in the TX
bool newData = false;

//===========

void setup() {

    Serial.begin(9600);

    Serial.println("SimpleRx Starting");
    radio.begin();
    radio.setDataRate( RF24_250KBPS );
    radio.openReadingPipe(1, thisSlaveAddress);
    radio.startListening();
}

//=============

void loop() {
    getData();
    showData();
}

//==============

void getData() {
    if ( radio.available() ) {
        radio.read( &dataReceived, sizeof(dataReceived) );
        newData = true;
    }
}

void showData() {
    if (newData == true) {
        Serial.print("Data received ");
        Serial.println(dataReceived);
        newData = false;
    }
}

The transmitter seemed to be working fine printing in the serial monitor:

13:05:22.966 -> Data Sent Message 3  SimpleTx Starting
13:05:25.437 -> Data Sent Message 0  Acknowledge received
13:05:26.436 -> Data Sent Message 1  Acknowledge received
13:05:27.434 -> Data Sent Message 2  Acknowledge received
13:05:28.432 -> Data Sent Message 3  Acknowledge received
13:05:29.432 -> Data Sent Message 4  Acknowledge received
13:05:30.432 -> Data Sent Message 5  Acknowledge received
13:05:31.427 -> Data Sent Message 6  Acknowledge received

The number is being printed incrementing it by 1 after each iteration, every second after sending it successfully(radio.write() returns a true) which is what it is supposed to do. However, the problem seems to be on the receiver side:

13:06:20.318 -> Data received⸮SimpleRx Starting
13:06:21.798 -> Data received 
13:06:21.831 -> Data received 
13:06:21.831 -> Data received 
13:06:21.864 -> Data received 

It prints data received rapidly. Following the tutorial

the output of radio.printDetails() is

SPI Speedz	= 10 Mhz
STATUS		= 0x00 RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=0 TX_FULL=0
RX_ADDR_P0-1	= 0x0000000000 0x0000000000
RX_ADDR_P2-5	= 0x00 0x00 0x00 0x00
TX_ADDR		= 0x0000000000
RX_PW_P0-6	= 0x00 0x00 0x00 0x00 0x00 0x00
EN_AA		= 0x00
EN_RXADDR	= 0x00
RF_CH		= 0x00
RF_SETUP	= 0x00
CONFIG		= 0x00
DYNPD/FEATURE	= 0x00 0x00
Data Rate	= 1 MBPS
Model		= nRF24L01+
CRC Length	= Disabled
PA Power	= PA_MIN
ARC		= 0

Yes, it has all 0x00 and the arduino is not properly communicating with the NRF. I tried powering the NRF module with 2 alkaline AA batteries(1.5 V each). The transmitter works as before, but no luck with the receiver. I even connected a 10 μF capacitor between the power supply to the NRF but no luck. I changed the NRF module for the receiver but the "data received" flooding doesn't change.

P.S: I am using a clone of Arduino Nano, but it seem to be working fine with other applications. The NRF24L01 module has "NRF24L01" printed on its chip.

What happens if you swap the roles of the Arduinos ?
What happens if you swap the radio modules between the Arduinos ?

Does the problem follow the Arduino or radio module ?

Thank you, Mr. UKHeliBob. Swapping the arduino's with the same nrf doesn't change the output for the transmitter on the serial monitor. But swapping the NRF's show some difference.
NRF 1 with both Arduino's:

15:45:21.822 -> SimpleTx Starting
15:45:22.955 -> Data Sent Message 0  Tx failed
15:45:23.955 -> Data Sent Message 0  Acknowledge received
15:45:25.057 -> Data Sent Message 1  Tx failed
15:45:26.057 -> Data Sent Message 1  Acknowledge received
15:45:27.124 -> Data Sent Message 2  Acknowledge received
15:45:28.223 -> Data Sent Message 3  Acknowledge received
15:45:29.290 -> Data Sent Message 4  Acknowledge received
15:45:30.390 -> Data Sent Message 5  Acknowledge received
15:45:31.456 -> Data Sent Message 6  Acknowledge received
15:45:32.523 -> Data Sent Message 7  Acknowledge received
15:45:33.623 -> Data Sent Message 8  Acknowledge received
15:45:34.689 -> Data Sent Message 9  Acknowledge received
15:45:35.787 -> Data Sent Message 0  Tx failed
15:45:36.786 -> Data Sent Message 0  Acknowledge received
15:45:37.850 -> Data Sent Message 1  Acknowledge received
15:45:38.948 -> Data Sent Message 2  Tx failed
15:45:39.945 -> Data Sent Message 2  Acknowledge received
15:45:41.043 -> Data Sent Message 3  Tx failed
15:45:42.076 -> Data Sent Message 3  Acknowledge received
15:45:43.143 -> Data Sent Message 4  Tx failed
15:45:44.143 -> Data Sent Message 4  Acknowledge received
15:45:45.243 -> Data Sent Message 5  Tx failed
15:45:46.243 -> Data Sent Message 5  Acknowledge received
15:45:47.344 -> Data Sent Message 6  Tx failed
15:45:48.345 -> Data Sent Message 6  Acknowledge received

NRF 2 with both Arduino's

15:47:12.133 -> Data Sent Message 7  SimpleTx Starting
15:47:14.611 -> Data Sent Message 0  Acknowledge received
15:47:15.611 -> Data Sent Message 1  Acknowledge received
15:47:16.611 -> Data Sent Message 2  Acknowledge received
15:47:17.611 -> Data Sent Message 3  Acknowledge received
15:47:18.612 -> Data Sent Message 4  Acknowledge received
15:47:19.614 -> Data Sent Message 5  Acknowledge received
15:47:20.613 -> Data Sent Message 6  Acknowledge received
15:47:21.613 -> Data Sent Message 7  Acknowledge received
15:47:22.614 -> Data Sent Message 8  Acknowledge received
15:47:23.611 -> Data Sent Message 9  Acknowledge received

Well, the module NRF 1 fails to transmit data packets on some occasions. For receiver both receive a flood of data packets. I think I should try with more NRF modules and Arduinos.

Brought a fresh pair of Arduino Nanos and NRF24L01s, if I label them Arduino1, Arduino2, NRF1, NRF2:

Swapping the arduinos(Before: Ardiono1+NRF1=Receiver, Ardiono2+NRF2=Transmitter), the Serial Monitor for the Transmitter shows "Data Sent Message 0 Acknowledge received", while the Receiver is flooded with "Data received".
(After: Ardiono2+NRF1=Receiver, Ardiono1+NRF2=Transmitter), , the Serial Monitor for the Transmitter shows "Data Sent Message 0 Acknowledge received", while the Receiver is flooded with "Data received".

Swapping the NRFs, (Before: Ardiono1+NRF1=Receiver, Ardiono2+NRF2=Transmitter), the Serial Monitor for the Transmitter shows "Data Sent Message 0 Acknowledge received", while the Receiver is flooded with "Data received".
(Before: Ardiono1+NRF2=Receiver, Ardiono2+NRF1=Transmitter), the Serial Monitor for the Transmitter shows "Data Sent Message 0 Acknowledge received", while the Receiver is flooded with "Data received".

The transmitter seems to be working fine for all combinations of Arduino and NRFs, but the receiver doesn't seem to work.

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