nRF24l01 not working

Dear all,

Yesterday two nRF24l01 boards arrived and I have tried to connect one to an Arduino Uno (transmitter) and the other to an Arduino Nano (receiver), both via an nRF24l01 adapter.

In the image below, the electrical wiring is given for the arduino nano.

The connections for the uno are similar.
For the sake of clarification, the wires are connected as such:
Adapter <-> Nano/Uno
Vcc <-> 5V (5V is required for the adapter, internally it is converted to 3v3)
GND <-> GND
CE <-> D9
CSN <-> D10
SCK <-> D13
M0/MOSI <-> D11
M1/MISO <-> D12
IR0 not connected

The transmitter code (Arduino Uno) is as follows (code based on tutorial Arduino nRF24l01 tutorial :

// 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 receiver code (Arduino Nano), again based on this tutorial Arduino nRF24l01 tutorial :

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

Unfortunately, if I connect and upload the sketches to the Uno and Nano (via two different USB ports on one laptop) this is all I get:

So the transmitter prints in the Serial monitor that the data delivery failed. I have checked the connections multiple times, I have tried older versions of the RF24 library and the most recent version, but nothing seems to work..

Anyone who might have a clue on what is going wrong here?

i'll try uploading this to my board but its highly likely that the fault is with nrf board. most of them out there in the market are bogus and dont work. plus they are going obsolete and are not recommended for use. will le you know what i get. altho there is another topic in this forum that has a code which checks if the csn pin is working. its not a permanent solution but will lwt you know if the nrf is good upto some extent.

There is a CheckConnection.ino sketch further along in the tutorial that you linked to ( post #30 ). It may help to post the output if that sketch for both setups.

recently been experimenting with six NRF24L01 of which only two work
if you have a ESP32 try the working code in post esp32-with-nrf24l01 (connect NRF24L01 directly to the ESP32 not via an adapter)

consider an alternative wireless technology, e.g. WiFi, LoRa, Bluetooth, etc - what is the project?

I just tried these nRF24l01 modules with Arduino UNO and Arduino Mega 2560.
I used RadioHead library.
For Arduino Uno I found right away the info about pin connection with nRF24l01.
But for Mega 2560 there was a lot of wrong info on the web.
The problem was with pins 3 and 4 that I was not sure where to connect them.
After trying several times, this is what worked for me:

nrf24-radiohead-with-Arduino

For ESP8266 (NodeMcu 1.0 ESP-12E) and ESP32 (ESP32 Wroom 32) I was not able to use RadioHead library. Is giving me some compile errors (utils/atomic.h not found). So I give up on this lib.
I tried RF24 library and it compiles ok for Arduino and ESP.

rf24-lib-arduino-esp-connections

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