NRF24L01 not working with arduino uno and nano

Hello everyone.
I bought 2 NRF24L01 + PA + LNA and I'm trying to make them work, but I can't.
I have this model so I can plug my radios to Arduino 5v.

CE --> D9
CSN --> D10
SCK --> D13
MOSI --> D11
MISO --> D12

VCC --> 5v
GND --> GND

I made those connections with 1 radio with a Nano and 1 with and a Uno.

In my code, I used radio.isChipConnected and it seems that my connections are ok because it returns yes with the 2 arduinos.

BUT, when I copy a code from a website or a forum, I can't send or receive datas and I don't know why. I tried 5 codes, changed all my wires, used a 3,3v converter, inversed the radios, but nothing worked.

Here one of my code (from this topic)

for the transmitter :

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

and for the receiver :

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

In the console, I get this from the transmitter :
SimpleTx Starting
Data Sent Message 0 Tx failed
Data Sent Message 0 Tx failed
Data Sent Message 0 Tx failed
Data Sent Message 0 Tx failed

And this from the receiver :
SimpleRx Starting

If you have any ideas, please help me because I have a deadline.
Thank you everyone

Robin's examples are known to work. Have you tried the connection test sketch from the same topic ?

+1 on running the connection test sketch in post #30 of Robin2's tutorial. Post the results for master and slave.

Are the radio modules powered from the adapters? Lack of power is the most prevalent problem when using the RF24s.

How far apart are the master and slave? They need to be a few meters apart.

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.

Ok, here are the results for master and slave (i think it's the same code)

RX :

SPI Speedz	= 10 Mhz
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 0x20 0x20 0x20 0x20 0x20
EN_AA		= 0x3f
EN_RXADDR	= 0x03
RF_CH		= 0x4c
RF_SETUP	= 0x07
CONFIG		= 0x0e
DYNPD/FEATURE	= 0x00 0x00
Data Rate	= 1 MBPS
Model		= nRF24L01+
CRC Length	= 16 bits
PA Power	= PA_MAX
ARC		= 5


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

SPI Speedz	= 10 Mhz
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		= 0x4141417852
RX_PW_P0-6	= 0x20 0x20 0x20 0x20 0x20 0x20
EN_AA		= 0x3f
EN_RXADDR	= 0x03
RF_CH		= 0x4c
RF_SETUP	= 0x27
CONFIG		= 0x0e
DYNPD/FEATURE	= 0x00 0x00
Data Rate	= 250 KBPS
Model		= nRF24L01+
CRC Length	= 16 bits
PA Power	= PA_MAX
ARC		= 5

TX :

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

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

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

The arduinos are powered with the USB port (1 computer each) and are a meter away.

I powered them with 12v in jack and put them 10 meters away : looks good i think
I got in the console :
Data received Message 0
... (same message between 1 and 7 times)
Data received Message 1
...
Data received Message 2
...
etc up to 9 so i think it maybe works correctly.

The standard setting is full power, so your high power modules probably overwhelmed each other.

You can use setPALevel to control the used power level.

https://nrf24.github.io/RF24/classRF24.html#ab6a711a9cc14fb459a4a1698b8665d82

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