Communication issue with NRF24L01

Hi everyone,

I'm trying to use the NRF24L01 to establish communication between two Arduinos (Arduino UNO and a micro pro).

For the moment, I'm having a problem with the Receiver (micro pro). I think it's a communication problem between the arduino and the module. When I upload the testing code from Simple nRF24L01+ 2.4GHz transceiver demo - Exhibition / Gallery - Arduino Forum (slightly modified, at the end) I get the following results:

CheckConnection Starting

FIRST WITH THE DEFAULT ADDRESSES after power on
Note that RF24 does NOT reset when Arduino resets - only when power is removed
If the numbers are mostly 0x00 or 0xff it means that the Arduino is not
communicating with the nRF24

STATUS = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1 = 0xe7e7e7e7e7 0xc2c2c2c2c2
RX_ADDR_P2-5 = 0xc3 0xc4 0xc5 0xc6
TX_ADDR = 0xe7e7e7e7e7
RX_PW_P0-6 = 0x00 0x00 0x00 0x00 0x00 0x00
EN_AA = 0x3f
EN_RXADDR = 0x03
RF_CH = 0x02
RF_SETUP = 0x0f
CONFIG = 0x08
DYNPD/FEATURE = 0x00 0x00
Data Rate = 2MBPS
Model = nRF24L01+
CRC Length = 8 bits
PA Power = PA_MAX

AND NOW WITH ADDRESS AAAxR 0x41 41 41 78 52 ON P1
and 250KBPS data rate

STATUS = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1 = 0x4141417852 0x4141417852
RX_ADDR_P2-5 = 0xc3 0xc4 0xc5 0xc6
TX_ADDR = 0xe7e7e7e7e7
RX_PW_P0-6 = 0x20 0x20 0x00 0x00 0x00 0x00
EN_AA = 0x3f
EN_RXADDR = 0x03
RF_CH = 0x02
RF_SETUP = 0x27
CONFIG = 0x08
DYNPD/FEATURE = 0x00 0x00
Data Rate = 250KBPS
Model = nRF24L01+
CRC Length = 8 bits
PA Power = PA_MAX

STATUS = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1 = 0xe7e7e7e7e7 0xc2c2c2c2c2
RX_ADDR_P2-5 = 0xc3 0xc4 0xc5 0xc6
TX_ADDR = 0xe7e7e7e7e7
RX_PW_P0-6 = 0x00 0x00 0x00 0x00 0x00 0x00
EN_AA = 0x3f
EN_RXADDR = 0x03
RF_CH = 0x02
RF_SETUP = 0x0f
CONFIG = 0x08
DYNPD/FEATURE = 0x00 0x00
Data Rate = 2MBPS
Model = nRF24L01+
CRC Length = 8 bits
PA Power = PA_MAX

For some reason, the settings are "lost" after I call the radio.startListening() function. Does anyone have any idea why this is happening? If more details are required, just let me know.

I'm using the following connection:

I also tried two different NRF24L01 modules and had the same problem.

Code:

// 18 Mar 2018 - simple program to verify connection between Arduino
//      and nRF24L01+
//  This program does NOT attempt any communication with another nRF24

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

#include <printf.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() {
    delay(10000);

    Serial.begin(9600);
    printf_begin();

    Serial.println("CheckConnection Starting");
    Serial.println();
    Serial.println("FIRST WITH THE DEFAULT ADDRESSES after power on");
    Serial.println("  Note that RF24 does NOT reset when Arduino resets - only when power is removed");
    Serial.println("  If the numbers are mostly 0x00 or 0xff it means that the Arduino is not");
    Serial.println("     communicating with the nRF24");
    Serial.println();
    radio.begin();
    radio.printDetails();
    Serial.println();
    Serial.println();
    Serial.println("AND NOW WITH ADDRESS AAAxR  0x41 41 41 78 52   ON P1");
    Serial.println(" and 250KBPS data rate");
    Serial.println();
    radio.openReadingPipe(0, thisSlaveAddress);
    radio.openReadingPipe(1, thisSlaveAddress);
    radio.setDataRate( RF24_250KBPS );
    radio.printDetails();
    radio.startListening();
    radio.printDetails();
    Serial.println();
    Serial.println();
}


void loop() {
}

Another important thing that I forgot to mention. I'm using a step-down converter to convert 5V to 3.3V. The converter that I'm using is the MP1584EN.

I also tried to add a capacitor between VCC and GND, but it didn't change anything.

You have posted three sets of output for the nRF24 connection test but I would expect 2 or 4 sets as the test output is always in pairs.

I can't make sense of your Fritzing diagram. Please just use pencil and paper to draw a clearly labelled diagram and post a photo of it.

I can't understand how you can say "the settings are "lost" after I call the radio.startListening()". You need to describe in great detail how you test for that. There is no reason that I am aware of for that function to affect the settings.

I presume you are starting with first example from my Tutorial with NO changes to my code? If not, then that's the place to start. There is no point trying anything more complicated if that example does not work.

...R
Simple nRF24L01+ Tutorial

Thanks for your response. Let me clarify.

The code that I'm using (present at the end of the first post) is a modification of your code. The only change is that I call the startListening function at the end and then call the radio.printDetails again.

With that in mind, the code will show 3 outputs (radio.printDetails). The first two show the changes sent to the module (in red). For example, the RX_ADDR_P0-1 and Data Rate were changed. Finally, I say that the device lost the settings because, in the last one, both RX_ADDR_P0-1 and Data Rate go back to the default values.

I've never used this type of module before, so I may be missing something basic.

It will be much easier to help you if you use the programs from my Tutorial with NO CHANGES. I know they work.

...R

Ok, let me go back one step. I was trying to give a more specific problem.

The first thing that I tried was using your "Simple one way transmission" code, exactly as it is.

With this one, I would get "Data Sent Message 0 Tx failed" on the transmitter and nothing on the Receiver. Then, I added a radio.printDetails on both of them and I noticed that the receiver has default values for RX_ADDR_P0-1.

On the transmitter I would get:

STATUS = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1 = 0x4141417852 0xc2c2c2c2c2
RX_ADDR_P2-5 = 0xc3 0xc4 0xc5 0xc6
TX_ADDR = 0x4141417852
RX_PW_P0-6 = 0x20 0x00 0x00 0x00 0x00 0x00
EN_AA = 0x3f
EN_RXADDR = 0x03
RF_CH = 0x4c
RF_SETUP = 0x07
CONFIG = 0x0e
DYNPD/FEATURE = 0x00 0x00
Data Rate = 1MBPS
Model = nRF24L01+
CRC Length = 16 bits
PA Power = PA_MAX

but on the receiver I would get:

STATUS = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1 = 0xe7e7e7e7e7 0xc2c2c2c2c2
RX_ADDR_P2-5 = 0xc3 0xc4 0xc5 0xc6
TX_ADDR = 0xe7e7e7e7e7
RX_PW_P0-6 = 0x00 0x00 0x00 0x00 0x00 0x00
EN_AA = 0x3f
EN_RXADDR = 0x03
RF_CH = 0x02
RF_SETUP = 0x0f
CONFIG = 0x08
DYNPD/FEATURE = 0x00 0x00
Data Rate = 2MBPS
Model = nRF24L01+
CRC Length = 8 bits
PA Power = PA_MAX

As we can see, the RX_ADDR_P0-1 is not showing the same address. As far as I understand, they are not using the same channel.

The modified code that I used is presented below:

Transmitter

// SimpleTx - the master or the transmitter

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <printf.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");
    printf_begin();
    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");
        radio.printDetails();
    }
}

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

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

receiver

// SimpleRx - the slave or the receiver

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <printf.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);
    delay(5000);
    Serial.println("SimpleRx Starting");
    radio.begin();
    radio.setDataRate( RF24_250KBPS );
    printf_begin();
    radio.openReadingPipe(1, thisSlaveAddress);
    radio.startListening();
    radio.printDetails();
    
}

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

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

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

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

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

navierstonks:
Ok, let me go back one step. I was trying to give a more specific problem.

The first thing that I tried was using your "Simple one way transmission" code, exactly as it is.

With this one, I would get "Data Sent Message 0 Tx failed" on the transmitter and nothing on the Receiver. Then, I added a radio.printDetails on both of them

Let's try not adding anything - it just confuses the matter.

Have you tried the connection test program in the way I intended it to be used? And for both of your Arduinos?

...R