Can't get NRF24L01+ to work - hardware issue?

Hello, I'm super new to using Arduino, so my level of knowledge is pretty much just what I can decode from tutorials.

I cannot seem to get my NRF24L01+ modules to communicate with each other, and I can't figure out what the problem is.

I'm using two Arduino Unos, each with an NRF (see wiring diagram).

I've been trying to use a variety of codes to get it to work, and I followed Robin2's Simple tutorial here, trying several of their sample codes, every one giving me a variety of error codes and/or nonresponses. Here's the SimpleTx and SimpleRx codes I've been using for my master and slave, respectively:

// SimpleTx - the master or the transmitter

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


#define CE_PIN   5
#define CSN_PIN 7

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");
   pinMode(10,OUTPUT);

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

(I intend on using the SS pin for a secondary device on my master, which is why I switched the pins around. However, I've done no such thing for the slave Uno and that seems to make no difference)

The error I get with this is

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
Data Sent Message 0  Tx failed

Over and over again, about once a second.

For the slave:

// 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 only thing I get in the serial monitor is:

SimpleRx Starting

I have about 10 NRF24 modules that I've switched out, four of which I've soldered 10uf capacitors onto the GND and VCC pins just in case, and I also have a spare Uno that I've switched out as well.

I've also tried rolling back the RF24 library to the 1.1.17 that was suggested in that thread, and I've tried the Getting Started code, as well as Robin's ackPayload example in that same thread.

I've also tried the Check Connection code that was posted

// 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() {
    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() {

}

And I get the 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	 = 0x000000001c 0x0000000070
RX_ADDR_P2-5	 = 0x38 0x38 0x1c 0xc6
TX_ADDR		 = 0x6c6c6c6cec
RX_PW_P0-6	 = 0xe0 0x1c 0xe0 0x38 0x38 0x1c
EN_AA		 = 0x3f
EN_RXADDR	 = 0x1c
RF_CH		 = 0x38
RF_SETUP	 = 0x1c
CONFIG		 = 0x08
DYNPD/FEATURE	 = 0x38 0x38
Data Rate	 = 2MBPS
Model		 = nRF24L01
CRC Length	 = 8 bits
PA Power	 = PA_HIGH


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	 = 0x000000001c 0x0000000070
RX_ADDR_P2-5	 = 0x38 0x38 0x1c 0xc6
TX_ADDR		 = 0x6c6c6c6cec
RX_PW_P0-6	 = 0xe0 0x1c 0xe0 0x38 0x38 0x1c
EN_AA		 = 0x3f
EN_RXADDR	 = 0x1c
RF_CH		 = 0x38
RF_SETUP	 = 0x1c
CONFIG		 = 0x08
DYNPD/FEATURE	 = 0x38 0x38
Data Rate	 = 2MBPS
Model		 = nRF24L01
CRC Length	 = 8 bits
PA Power	 = PA_HIGH


Which to me says it has a clear connection?
I really though it was my hardware, but I've double and triple checked my connections, switched out my wires, switched out my microcontrollers, added capacitors, and cycled through all 10 of my RF24s... so it must be something with my setup. Any help appreciated.

I'm a new user, and I could only put one picture in this post. Here is a diagram of my slave Uno

Do you have caps on the 3.3V supplies close to the radios?

Here are some things to try.

Make sure the rf24 power supply can provide enough current. This is especially true for the high power (external antenna) modules. I use homemade adapters like these. They are powered by 5V and have a 3.3V regulator on the board.

If using the high powered radios make sure to separate them by a few meters. They may not work too close together.

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 );

I tried the posted master and slave codes on 2 Unos with rf24 radios attached. I had to change the master (transmitter) CE and CSN pins to match my hard wired setup. I get good communications so the code is good. My experience is that insufficient power is the biggest culprit in getting the rf24 radios to work. Note the both radios, in my setup, are powered by their own 3.3V regulators per the previous post.

This is a pic of the capacitor, should I have put it somewhere else?

I don't have the high powered radios, I don't believe. I have these

I do also sometimes add

radio.setPALevel(RF24_PA_LOW);

to my code, though it seems to not do anything. I also assume that since I'm switching out my radios so often, I think that counts as power cycling them, which also doesn't help.

I assume it's a power thing then, like you said -- I think I'll try those adapters that you linked and see if they help. Is there any other way to increase power in the meantime? Like if I have a battery also hooked up to the Uno (in addition to the computer USB) would that boost the power or be redundant?

Thanks for your help

That is the proper place for the cap.

Robin2 (the author of the simple rf24 tutorial) would recommend powering the radios with a 2 AA cell pack. Disconnect the Vcc of the radio from the 3.3V of the Uno and connect the plus of the battery to rf24 Vcc, only. Connect the minus (ground) of the battery to rf24 ground and Uno ground.

Okay I will get ahold of a cell pack and those adaptors and try them out. Thanks for your help

Make sure the two units are at least 3 meters (10 feet) apart.

The test sketch in post 1 appears to have failed. The data rate Change has not been respected.

This test, taken from post #1, shows incorrect results. The attempt to change the data rate to 250KBPS has failed. Check the wiring carefully and compare a number of devices.

EDIT
Also the 8 bit CRC length looks odd. The standard is 16 bits and that is required for Autoack and it has to match in both the RX part and the TX part. And, worse, your model has no '+' following the nRF24L01 type designation.

I'm not sure how representative the following test result is, but it looks better that yours at least in respect of the above mentioned points.

LINK

Simple nRF24L01+ 2.4GHz transceiver demo - #63 by tamoorh1

These models were labeled as nRF24L01+ when I bought them -- I wonder if that means I have faulty modules.

I see what you mean with the Data Rate and CRC Length -- I must have a connection problem somewhere.

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