NRF24L01 COM problems

Hi !!

I´m getting a bit frustrated on the nrf devices..

I´m using an Arduino UNO as Transciver and an 5 to 3.3V adapter for the NRF24 like this:

For reciever i´m using an RF Nano (built in NRF)

I have followed Robin2 example : Simple nRF24L01+ 2.4GHz transceiver demo - #28 by nurulb

I´m running Arduino 1.8.16 and using the 1.1.7 RF24 library.

TX Code:

#include <SPI.h>

// SimpleTx - the master or the transmitter

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

// UNO
#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;
}

RX Code: `// SimpleRx - the slave or the receiver

#include <nRF24L01.h>
#include <RF24.h>
// RF Nano
#define CE_PIN  10
#define CSN_PIN 9

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 only thing changed to the code is: // UNO and // Nano to keep track of wich code to wich board, And CE CSN pin to match the board.

When testing the Robin2 : CheckConnection.ino

/ 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  10
#define CSN_PIN 9
// UNO CE PIN 9 CSN PIN 10
// NANO CE PIN 10 CSN PIN 9

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);
    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(1, thisSlaveAddress);
    radio.setDataRate( RF24_250KBPS );
    radio.printDetails();
    Serial.println();
    Serial.println();
}


void loop() {

}

I get the following reply from Serial monitor:

In my eyes that look correct.

But why are the TX and RX code not working ????
In the serial monitor it looks like this:
TX:
image
RX:
image

Things i tried so far...
I have tried switching out the NRF24L01 modules // i have 10pcs of them.
I have tried using an regular nano, RFnano and an Nano 33IOT, still gets the check connection program to work.

I tried communicating between the nanos, still no data recieved.

I tried Uninstaling the RF24 1.1.7, reboot computer and installing the latest version 1.4.1 no luck there either.

I removed the power module for the NRF and connected it directly to the 3V uno, no luck.

How is it possible to have connection test ok between arduino and nrf with the connection test but no connection between NRF´s ??

I have tried putting the NRF close togheter and 2m apart, no luck.

Best Regards

Andreas

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the </> icon above the compose window) to make it easier to read and copy for examination

That the Arduino can talk to the NRF24 over the SPI interface does not mean the RF side of the NRF24 modules is working, the modules could have faulty RF bits.

I recommended using this one TXS0108E


when wiring remember to connect OE to VA side VA 1.6 to 3.3 VB is 1.6-> 5.5

The receiver appears to getting the data and is able to print Message 0.
However, the "ack" is not getting back to the transmitter so the transmitter doesn't know the message has been received.

This can be a power problem somewhere or it can also be the behaviour of a clone nrf24L01.

Hi !!

Thank you for the quick support ! :slight_smile:

I´m not sure the NRF24L01 are genuine, can i tell by looking at them?
https://zeptobars.com/en/read/Nordic-NRF24L01P-SI24R1-real-fake-copy
On my NRF chips, they all have: "NRF M 24L01+ 2012AH" printed on them.
Link to genuine NRF´s ??

Tonight i tried using different versions of the RF24 to the NANO33IOT with no luck, i tried powering the nrf from an external power supply 3V and off course common grounds to the arduino.
The Robin2 test connection code worked fine all the time.

I want to build an compact remote with an BN055 sensor and an arduino and and NRF or if there is any small easier to work with transreciver? Without having to try different versions of libraries. What is te most compact solution? I want to power it with some battery.

My reciever will be in an box and i was thinking arduino UNO and NRF.

I only want to send some data from the BNO055 max 15m.

Best Regards
Andreas

A couple more things to try.

Reset the radios by cycling power to them after uploading new code. I have found that to help. They do not reset with the Arduino.

Switch to 1MB data rate to catch the not so cloned clones.

radio.setDataRate( RF24_1MBPS );

Hi !

I have tried unplugging the arduinos and NRF after the sketch is uploaded with no luck.
I tried to change the

radio.setDataRate ( RF24_1MBPS ); 

With the following result:

Best Regards

Did you deliberately ignore the advice on posting code that I previously posted ?

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the </> icon above the compose window) to make it easier to read and copy for examination

Hi!!

I'm sorry for the misstake.

I have moved the code to inside post code brackets.

Is it allowed to post screenshots of the Serial monitor as i did? Or should that allso be in code brackets?
Best regards

Thanks for adding the code tags. I am sure that you can see how much easier to read and copy for examination.

Please copy the output from the Serial monitor and post that in code tags too

Its quite difficult for most people to read screenshot images, copy and post the text instead.

Now i have actually made som progress!! :slight_smile:

The RF Nano and Arduino 33IOT dident work with the code and latest RF24 lib.

The setup i´m trying now is:

Arduino UNO with 5-3V NRF adapter and NRF24LO1

Arduino Nano Mega328P ( OLD bootloader ) with 5-3V NRF adapter and NRF24LO1.

I have tried supplying power from external 5V to the 5-3V Nrf Adapter.

The comunicating dosent look so stable.
When i hold both NRF at the same time the communication is stable!!
I have tried putting an GND wire between the NRF and arduinos with no luck.

The RX code:

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

// UNO 

#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;
    }
}

TX Code:

// SimpleTx - the master or the transmitter

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

// Nano oldbootloader
#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;
}

Serial Monitor:

15:36:40.495 -> Data Sent Message 4  Tx failed
15:36:41.532 -> Data Sent Message 4  Tx failed
15:36:42.520 -> Data Sent Message 4  Tx failed
15:36:43.553 -> Data Sent Message 4  Tx failed
15:36:44.588 -> Data Sent Message 4  Tx failed
15:36:45.579 -> Data Sent Message 4  Tx failed
15:36:46.568 -> Data Sent Message 4  Tx failed
15:36:47.604 -> Data Sent Message 4  Tx failed
15:36:48.592 -> Data Sent Message 4  Tx failed
15:36:49.625 -> Data Sent Message 4  Acknowledge received
15:36:50.614 -> Data Sent Message 5  Acknowledge received
15:36:51.646 -> Data Sent Message 6  Tx failed
15:36:52.636 -> Data Sent Message 6  Tx failed
15:36:53.670 -> Data Sent Message 6  Tx failed
15:36:54.704 -> Data Sent Message 6  Tx failed
15:36:55.693 -> Data Sent Message 6  Tx failed
15:36:56.687 -> Data Sent Message 6  Acknowledge received
15:36:57.724 -> Data Sent Message 7  Tx failed
15:36:58.714 -> Data Sent Message 7  Acknowledge received
15:36:59.749 -> Data Sent Message 8  Tx failed
15:37:00.781 -> Data Sent Message 8  Tx failed
15:37:01.773 -> Data Sent Message 8  Tx failed
15:37:02.806 -> Data Sent Message 8  Tx failed
15:37:03.795 -> Data Sent Message 8  Tx failed
15:37:04.827 -> Data Sent Message 8  Tx failed
15:37:05.815 -> Data Sent Message 8  Tx failed
15:37:06.849 -> Data Sent Message 8  Tx failed
15:37:07.837 -> Data Sent Message 8  Tx failed
15:37:08.873 -> Data Sent Message 8  Tx failed
15:37:09.906 -> Data Sent Message 8  Tx failed
15:37:10.898 -> Data Sent Message 8  Tx failed
15:37:11.931 -> Data Sent Message 8  Tx failed
15:37:12.921 -> Data Sent Message 8  Tx failed
15:37:13.954 -> Data Sent Message 8  Tx failed
15:37:14.987 -> Data Sent Message 8  Tx failed
15:37:15.977 -> Data Sent Message 8  Tx failed
15:37:17.009 -> Data Sent Message 8  Tx failed
15:37:18.002 -> Data Sent Message 8  Tx failed
15:37:18.989 -> Data Sent Message 8  Acknowledge received
15:37:20.023 -> Data Sent Message 9  Tx failed
15:37:21.057 -> Data Sent Message 9  Tx failed
15:37:22.045 -> Data Sent Message 9  Tx failed
15:37:23.083 -> Data Sent Message 9  Tx failed
15:37:24.073 -> Data Sent Message 9  Tx failed
15:37:25.106 -> Data Sent Message 9  Tx failed
15:37:26.094 -> Data Sent Message 9  Acknowledge received
15:37:27.132 -> Data Sent Message 0  Tx failed
15:37:28.123 -> Data Sent Message 0  Acknowledge received
15:37:29.156 -> Data Sent Message 1  Tx failed
15:37:30.146 -> Data Sent Message 1  Tx failed
15:37:31.178 -> Data Sent Message 1  Tx failed
15:37:32.217 -> Data Sent Message 1  Tx failed
15:37:33.205 -> Data Sent Message 1  Tx failed
15:37:34.239 -> Data Sent Message 1  Tx failed
15:37:35.227 -> Data Sent Message 1  Tx failed
15:37:36.260 -> Data Sent Message 1  Tx failed
15:37:37.250 -> Data Sent Message 1  Tx failed
15:37:38.285 -> Data Sent Message 1  Tx failed
15:37:39.275 -> Data Sent Message 1  Tx failed
15:37:40.308 -> Data Sent Message 1  Tx failed
15:37:41.343 -> Data Sent Message 1  Tx failed
15:37:42.331 -> Data Sent Message 1  Tx failed
15:37:43.319 -> Data Sent Message 1  Acknowledge received
15:37:44.351 -> Data Sent Message 2  Tx failed

Serial Monitor:

16:16:16.972 -> Data received Message 8
16:16:18.009 -> Data received Message 8
16:16:27.144 -> Data received Message 8
16:16:28.132 -> Data received Message 9
16:16:29.127 -> Data received Message 0
16:16:30.161 -> Data received Message 1
16:16:31.152 -> Data received Message 2
16:16:32.140 -> Data received Message 3
16:16:33.127 -> Data received Message 4
16:16:34.165 -> Data received Message 5
16:16:35.154 -> Data received Message 6
16:16:36.142 -> Data received Message 7
16:16:43.244 -> Data received Message 8

Best Regards
Andreas

You could try commenting this out on both sides then it defaults to 1MBPS
radio.setDataRate( RF24_250KBPS );

You could also add this to both sides to put the radio on low power
radio.setPALevel(RF24_PA_LOW);

I tried the following changes you suggested:

// radio.setDataRate( RF24_250KBPS );
radio.setPALevel(RF24_PA_LOW);
6:55:47.406 -> Data Sent Message 0  Tx failed
16:55:48.529 -> Data Sent Message 0  Tx failed
16:55:49.607 -> Data Sent Message 0  Tx failed
16:55:50.598 -> Data Sent Message 0  Acknowledge received
16:55:51.677 -> Data Sent Message 1  Tx failed
16:55:52.803 -> Data Sent Message 1  Tx failed
16:55:53.879 -> Data Sent Message 1  Tx failed
16:55:54.866 -> Data Sent Message 1  Acknowledge received
16:55:55.991 -> Data Sent Message 2  Tx failed
16:55:57.070 -> Data Sent Message 2  Tx failed
16:55:58.059 -> Data Sent Message 2  Acknowledge received
16:55:59.184 -> Data Sent Message 3  Tx failed
16:56:00.262 -> Data Sent Message 3  Tx failed
16:56:01.385 -> Data Sent Message 3  Tx failed
16:56:02.418 -> Data Sent Message 3  Acknowledge received
16:56:03.543 -> Data Sent Message 4  Tx failed
16:56:04.623 -> Data Sent Message 4  Tx failed
16:56:05.704 -> Data Sent Message 4  Tx failed
16:56:06.737 -> Data Sent Message 4  Acknowledge received
16:56:07.819 -> Data Sent Message 5  Tx failed
16:56:08.899 -> Data Sent Message 5  Tx failed
16:56:10.022 -> Data Sent Message 5  Tx failed
16:56:11.014 -> Data Sent Message 5  Acknowledge received

When i set the:

// radio.setDataRate( RF24_250KBPS );

It works but not stable, when holding the boards there is no change in the stability.

When i set the :

radio.setPALevel(RF24_PA_LOW);

I get no communication att all.

Best Regards
Andreas

Since the code cannot know when you are holding the modules, that would imply its not a code problem.

No it dosent feel like an code issue, at the higher communication speed and holding the boards have no effect just at low Speed.

Have someone been able to setup and having an stable NRF communication or is this what to expect from NRF communication?

The modules I now have have work reliably, after I threw half of them away for not being reliable.

Ok so it's a bit of an lottery to use them. Is there any other option for an more stable solution with max 15m range?

Which NRF24L01 modules are you using ? There are 2 main types. Those which come with an antenna and power amplifier (usually described as NRF24L01 + LNA + PA) and basic modules with just the main NRF24L01 chip. Provide a link to the supplier page.

Can you show a picture of your installation with the standard Uno and standard Nano on which you last did your tests ?

That it did not work at all with the setting radio.setPALevel(RF24_PA_LOW); sounds odd. Could you isolate that to the transmitter and did you try swapping the modules (you said you had 10)