Trouble with nRF24L01

Hello everyone, Im having issues setting up 2 nRF24L01 trancievers. I want to establish a basic “Hello World” connection. Im using an arduino nano. I have read various forums and different articles but i cant find out whats wrong, I dont get any reading in the Serial monitor for the receiver. I have checked the wiring various times and changed the code and digital connections and it still doesnt work.

My connections on both devices are:
Ground-Ground
VCC-3.3v
CE-9
CSN-10
SCK-13
MOSI-11
MISO-12

I would appreciate any help or suggestions on how to make it work.

Thank you!

This is the code for the Transmitter

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(9, 10); // CE, CSN
const byte address[6] = "00001";
void setup() {
  radio.begin();
  radio.openWritingPipe(address);
  radio.setPALevel(RF24_PA_MIN);
  radio.stopListening();
}
void loop() {
  const char text[] = "Hello World";
  radio.write(&text, sizeof(text));
  delay(1000);
}

And this is the one for the receiver:

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(9, 10); // CE, CSN
const byte address[6] = "00001";
void setup() {
  Serial.begin(9600);
  radio.begin();
  radio.openReadingPipe(0, address);
  radio.setPALevel(RF24_PA_MIN);
  radio.startListening();
}
void loop() {
  if (radio.available()) {
    char text[32] = "";
    radio.read(&text, sizeof(text));
    Serial.println(text);
  }
}

Have a look at this Simple nRF24L01+ Tutorial.

Wireless problems can be very difficult to debug so get the wireless part working on its own before you start adding any other features.

The examples are as simple as I could make them and they have worked for other Forum members. If you get stuck it will be easier to help with code that I am familiar with. Start by getting the first example to work

There is also a connection test program to check that the Arduino can talk to the nRF24 it is connected to. If the first example does not work be sure to try the connection test for both of your Arduinos. Nothing will work if the connection test fails.

A common problem with nRF24 modules is insufficient 3.3v current from the Arduino 3.3v pin. This seems to be a particular problem with the nano. The high-power nRF24s (with the external antenna) will definitely need an external power supply. At least for testing try powering the nRF24 with a pair of AA alkaline cells (3v) with the battery GND connected to the Arduino GND.

If you are using the high-power nRF24s (with the external antenna) it may help to have a distance of about 3 metres between the two nRF24s so that the signal does not overwhelm the receiver. However someone on the Forum has had them working without that separation - I don't have any personal experience with them. If you are new to nRF24s it may be better to start with a pair of low power modules with the pcb antenna.

...R

I measured the output voltage in my arduino nano and i have a reading of 3.2V on both. I also tried using 2 AA to power the nRF24l01 and that also didnt work.

emd56:
I measured the output voltage in my arduino nano and i have a reading of 3.2V on both. I also tried using 2 AA to power the nRF24l01 and that also didnt work.

You are not giving me much to go on.

Have you tried the connection test program that is in my Tutorial? If that does not work then nothing will work.

...R

Ok so i tried the check connection test.
Here are the restults:
CheckConnection Starting

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 = 0x00
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 = 0x02
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

From what i understand it seems like is communicating with the arduino, however, I tried the simple one way transmission test and i couldnt get that to work.

emd56:
From what i understand it seems like is communicating with the arduino,

Correct. But you need to run the test on both Arduinos.

If the connection test works on both Arduinos but the simpleTx and simpleRx programs don't work then post the actual code that YOU have uploaded to your Arduinos and post a sample of the output from each Arduino.

Do you have some spare nRF24 modules in case one is faulty?

Are you using the high-power modules or the low power modules?

...R

Yes i ran the connection test on both arduinos and got the same results on both. Im using the low power modules.

Here is the code that im using for the arduinos:

**Transmitter: **

//Include Libraries
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>


//create an RF24 object
RF24 radio(9, 10);  // CE, CSN


//address through which two modules communicate.
const byte address[6] = "00001";


void setup()
{
  radio.begin();
  
  //set the address
  radio.openWritingPipe(address);
  
  //Set module as transmitter
  radio.stopListening();
}
void loop()
{
  //Send message to receiver
  const char text[] = "Hello World";
  radio.write(&text, sizeof(text));
  
  delay(1000);
}

And here is the one for the receiver side:

//Include Libraries
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>


//create an RF24 object
RF24 radio(9, 10);  // CE, CSN


//address through which two modules communicate.
const byte address[6] = "00001";


void setup()
{
  while (!Serial);
    Serial.begin(9600);
  
  radio.begin();
  
  //set the address
  radio.openReadingPipe(0, address);
  
  //Set module as receiver
  radio.startListening();
}


void loop()
{
  //Read the data if available in buffer
  if (radio.available())
  {
    char text[32] = {0};
    radio.read(&text, sizeof(text));
    Serial.println(text);
  }
}

There is no data in any of the serial monitors. And yes i have some extra modules i swapped one of them already and still no readings.

Robin2:
Correct. But you need to run the test on both Arduinos.

If the connection test works on both Arduinos but the simpleTx and simpleRx programs don’t work then post the actual code that YOU have uploaded to your Arduinos and post a sample of the output from each Arduino.

Do you have some spare nRF24 modules in case one is faulty?

Are you using the high-power modules or the low power modules?

…R

Following your tutorial, here is the code that i uploaded to the transmitter:

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

And here is the serial monitor on the Transmitter:
“SimpleTx Starting
Data Sent Message 0 Tx failed
Data Sent Message 0 Tx failed” and it continues like that

And here is the code for the receiver:

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

Serial monitor for the receiver:
“SimpleRx Starting”

emd56:
Following your tutorial, here is the code that i uploaded to the transmitter:

There are two questions in Reply #5 that you have not answered.

And a 3rd question ... have you got the required 10µF capacitor across the power supply for the nRF24s?

And a 4th ... what happens when you swap the Tx and Rx programs between the Arduinos?

And a 5th ... can you confirm that you tried the programs without any changes to the hardware after the successful connection test?

...R

Try putting a 10uf capacitor across the +3.3v and gnd of each of the nRF24L01 module.
If that dosen't work, run the nrf24l01 off its own supply, 3.3v but have seen these peak at 1A! sending bursts. and the poor Nano's 3.3V comes from the FT232 chip, only 50mA is available.

Fly AlaskasWorld

Robin2:
There are two questions in Reply #5 that you have not answered.

And a 3rd question ... have you got the required 10µF capacitor across the power supply for the nRF24s?

And a 4th ... what happens when you swap the Tx and Rx programs between the Arduinos?

And a 5th ... can you confirm that you tried the programs without any changes to the hardware after the successful connection test?

...R

Im using the low power modules. And yes i have more nrf24l01 modules.
I do not have the capacitors, i thought i wouldnt need them since i tried powering them with their own power supply. But ill order some and try that.
When i swap the program for the Tx and Rx i get the same resuts as before on the serial monitor:
"SimpleTx Starting
Data Sent Message 0 Tx failed
Data Sent Message 0 Tx failed" and it continues like that

Serial monitor for the receiver:
"SimpleRx Starting"
And i did not make any changes after the connection test.

It's very hard to know what else to suggest when I can't actually see your work bench.

Make sure to power down the Arduino after uploading the code to ensure that the nRF24 resets. The nRf24 does not reset when you activate an Arduino reset.

I reckon the first thing is to add the capacitors.

If that does not solve the problem then it may be that one or both of the nRF24 modules is faulty. It's impossible to tell which one so it would be good idea to change one for a spare and see if that makes a difference.

...R

Robin2:
It’s very hard to know what else to suggest when I can’t actually see your work bench.

Make sure to power down the Arduino after uploading the code to ensure that the nRF24 resets. The nRf24 does not reset when you activate an Arduino reset.

I reckon the first thing is to add the capacitors.

If that does not solve the problem then it may be that one or both of the nRF24 modules is faulty. It’s impossible to tell which one so it would be good idea to change one for a spare and see if that makes a difference.

…R

Ok, i ordered the capacitors, they will arrive in a couple of days. I will give you an update if that changes anything.
Thank you for your help! Ive been trying to get these to work for weeks.

I installed the 10uf capacitors and everything is working great! Thank you all.

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