[Solved] NRF24L01 receiver flooded with data packets

Ranjit Pal Asks: NRF24L01 receiver flooded with data packets
Following [this tutorial]Simple nRF24L01+ 2.4GHz transceiver demo I attempted making an NRF transmitter and receiver using an Arduino Nano. On the transmitter side I used the following code:

Code:
// 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;
}

The serial monitor prints

Code:
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

at 1 second intervals. I assume this points to an ‘okay’ transmitter. On the receiver side, I used the code

Code:
// 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;
    }
}

And the receiver gets flooded with data packets

Code:
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

The post also mentions that this is due to “most likely the Arduino is not communicating properly with its nRF24.” Following the recommendations, later in the thread, the output of radio.printDetails() is

Code:
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

There is some miscommunication as claimed by that post. I tried changing the pins of CE, CSN to 7,8 but the problem persisted for the receiver. I changed the power supply to the NRF using two alkaline AA batteries, but that didn’t solve the problem either. I also connected a 10 μF capacitor between the power supply pins of the NRF, but no luck. Next, I tried changing the NRF module. I used an NRF module which was working correctly as a transmitter(printing “Data Sent Message X Acknowledge received”) at 1 second, as intervals as a receiver in place, still the same problem.

Any help would oblige.

P.S: I am using Arduino clones, but they work for other purposes. The NRF’s have “NRF24L01” stamped on the chip, and seem to be fine.

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.