[SOLVED] Issues with nRF24L01p and Arduino Nano

I have been using nRF24L01 along with arduino Nano for quite a long time.

Currently i am trying to let nRF24L01p communicate with nRF24L01, but always sending from nRF24L01p fails. The same code works when communicating between two nRF24L01.

nRF24L01p printDetails are:

STATUS = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1 = 0xccccccccc3 0xcccccccc3c
RX_ADDR_P2-5 = 0x33 0xce 0x3e 0xe3
TX_ADDR = 0xcccccccee3
RX_PW_P0-6 = 0x20 0x20 0x20 0x20 0x20 0x20
EN_AA = 0x3e
EN_RXADDR = 0x3f
RF_CH = 0x5a
RF_SETUP = 0x21
CONFIG = 0x0f
DYNPD/FEATURE = 0x3f 0x04
Data Rate = 250KBPS
Model = nRF24L01+
CRC Length = 16 bits
PA Power = PA_MIN

Please any help would be much appreciated

The nRF24L01p (the one with external antenna) |500x333

The nRF24L01 (the one with built in antenna) |500x361

Edit 15/7/2017: Important tips and solution here : Solution + tips

Images from Original Post so we don't have to download them. See this Image Guide

|500x333

|500x361

...R

I don't recognize the part number "nRF24L01p". Do you mean nRF24L01+ ?

And are you trying to communicate with the earlier (obsolete?) versions with the +

If so the nRF24L01+ datasheet contains advice for doing that.

On the other hand your images suggest that you may be using two versions of the nRF24L01+ - the low powered version with the PCB antenna and the high powered version with the external antenna.

They should have no trouble communicating. However I believe the Arduino 3.3v pin cannot provide enough power for the high-power nRF24 and I also believe that if the two devices are too close to each other the high power can overload the other device.

...R Simple nRF24L01+ Tutorial

Robin2,

Sorry for the images i have updated the images and removed them from the attachments.

  • Unfortunately i do not have their part number as they are clones, but they look exactly as the images i have included in my first post. The nRF24L01p is the one with external antenna, while the nRF24L01 is the one with internal antenna

  • Yes you are right i am using two versions, but they are both nRF24L01+ as indicated by radio.printDetails()

Here is what i have done, so far, but none worked: 1. Tried to power them through an external source using a 3.3v regualtor 2. Added a 10uF capacitor (as i usually does) between the GND and VCC of the nRD24L01+ 3. The nRF with built-in antenna can send to the nRF with the external, but not the other way round. 4. I changed the jumper cables(even removed the jumper cables from an operating unit) 5. Used a longer jumper cable

You have not said if the two nRF24s are close together. Try them (say) 10 metres apart with capacitors and with external 3.3v power.

Have you a third nRF24 that you can use as a substitute to check if either of the first 2 is faulty?

I don't have any of the high-power versions myself so I have no direct experience of them.

...R

Hi Robin2,

Here is what I have done (in addition to the previous five steps), none worked:

  • I tried the 10m distance
  • Swapped the arduino nano ( got one that was working and attached to it the unit with the external antenna)
  • All the units with the builtin antennas are working as i have been using them right before de-attaching them and attaching the nrf with the external antenna.

Transmitter Code

#include "SPI.h"            
#include <RF24.h>    
#include <printf.h>       

RF24 radio(7, 8);  

uint8_t addr [] = {"ndo1"};
int a = 1;

void setup() {
 radio.begin(); 
 Serial.begin(9600);
 printf_begin();
 radio.setChannel(99); 
 radio.setPALevel(RF24_PA_MAX);          
 radio.setAddressWidth(4);               
 radio.openWritingPipe(addr);      
 radio.setRetries(15, 2);                
 radio.setPayloadSize(sizeof(a));                
 radio.setDataRate(RF24_250KBPS);        
 radio.setCRCLength(RF24_CRC_8);         
 radio.stopListening();   
 radio.powerUp();               
 radio.setAutoAck(true);      
 radio.printDetails();          
 }
void loop() {
  a*=2;
  bool value =radio.write(&a, sizeof(a));
  Serial.print("Trying to write:");
  Serial.print(a);
  Serial.print("     ---->   Result:");
  Serial.println(value==true?"Success":"Failure");
 if (a > 16201) { a = 1 ;}
 delay(1000);
}

Receiver Code

#include <SPI.h>            
#include "RF24.h"           
#include <stdint.h>
//#include <Servo.h>
#include <printf.h>


//rf2401
RF24 radio(7, 8); 
int a = 0;
int channel=0;
uint8_t addr [] = {"ndo1"}; 
uint8_t pn = 1;

void setup() {
  radio.begin();
  Serial.begin(9600);
  printf_begin();

 radio.setChannel(99);
 radio.setPALevel(RF24_PA_MAX);
 radio.setAddressWidth(4);
 radio.setPayloadSize(sizeof(a)); 
 radio.setDataRate(RF24_250KBPS);
 radio.setCRCLength(RF24_CRC_8);
 radio.setAutoAck(false);
 radio.openReadingPipe(pn, addr); 
 radio.powerUp();
 radio.printDetails();
 radio.startListening();
 

}

void loop() {
  //radio.openReadingPipe(pn, addr);
  if (radio.available(&pn)) {
    radio.read(&a, sizeof(a));
    //radio.closeReadingPipe(1);
    Serial.print("Got:");
    Serial.println(a);    
  }
  else  {
    Serial.println("NC");

  }

  delay(500);

}

Would a bigger capacitor, say 47uF make a difference ?

How could i check if the nrf with the external antenna is faulty?

Thanks :slight_smile:

boshkash1151:
How could i check if the nrf with the external antenna is faulty?

Getting a 2nd one is all I can think of.

If you have a suitable 3.3v power supply I don’t think the bigger capacitor would be needed - but if you have a bigger one handy try it.

…R

Robin2,

I added a larger capacitor found a 470uF, but still the issue persist.

Unfortunately I won’t be able to get a new one at the time being.

Also why does the nrf with the external antenna works when receiving data while fails to send ?.

I think the problem has to do with the autoack because when autoack is turned on a Scenario:

  1. Two units one with built-in antenna (let it be A) and the other with external antenna(let it be B)
  2. AutoACK is enabled on both unit A & B
  3. Unit A sends data to unit B and unit B recieves what A sends.
  4. Unit A indicate that send failed although B actually recieves what A had sent.

Could that help in solving the issue ?

Thanks

boshkash1151: Also why does the nrf with the external antenna works when receiving data while fails to send ?.

I have no idea

I think the problem has to do with the autoack because when autoack is turned on a Scenario: 1. Two units one with built-in antenna (let it be A) and the other with external antenna(let it be B) 2. AutoACK is enabled on both unit A & B 3. Unit A sends data to unit B and unit B recieves what A sends. 4. Unit A indicate that send failed although B actually receives what A had sent.

It is certainly possible for B to receive the data and for the sending of the acknowledgment to fail. But that failure might be because the ack was not sent properly by B or not received properly by A.

After uploading any program power down and the restart the Arduino to make sure the nRF24 restarts. The normal Arduino reset does not reset the nRF24.

Have you tried the first of my simple examples? And try the high-power nRF24 in both roles to see if it makes a difference.

...R

Robin2,

By disabling setAutoAck the high power antenna now can send data to the built in antenna, but of course some packets are dropped. success rate is 99.01%

Is it possible to enable the autoack and still be able to send/receive data ?

Thanks a lot

If you have two devices using the same address acks from that address will fail by collision.

Whandall: If you have two devices using the same address acks from that address will fail by collision.

I think you mean two receiving devices listening for the same address - and thus both sending an ack at the same time.

AFAIK the OP only has a pair of nRF24s - once sending to the other.

boshkash1151: By disabling setAutoAck the high power antenna now can send data to the built in antenna, but of course some packets are dropped. success rate is 99.01%

As I said earlier I have no experience with the high-power nRF24 devices

You have not said whether you have tried my code?

...R

@Robin2,

I tried your code and it works only when i disable the autoack

@Whandall, I turned off all other devices to limit interferences, so currently only one sending device and one receiving device are action

If you can send but not acknowledge (which is nothing more than a standard send without data), there is some misconfiguration hidden somewhere. You ruled out duplicate addresses, so it has to be something else.

If the retry period is too short the retry clashes the acknowledge, this can happen when using lower bitrates and/or acknowledge data.

Your setting of 4000µs is save but only configured in the sender, not the receiver, why?

Why do you use such a strange setup (4 byte addresses, 8-bit CRC, long retry delay but only two attempts)?

Using PA_MAX with PA beween near by modules can be problematic (but would impact sends like acks).

@Whandall,

the 4000us is missing from the receiver because I was just playing with numbers

The strange setup I copied it from another post actually i do not have preference. What values do you suggest ?

You suggest the following : 1. Change the retry to 4000us on both sender and reciever 2. Change PA to PA_MIN

Anything else?

Thanks,

boshkash1151: The strange setup I copied it from another post actually i do not have preference. What values do you suggest ?

Standard would be 5 byte addresses and 16 Bit CRC.

Some people encountered problems with high power settings, I normally run my tests with 2MBit and PA_MAX.

Do you use a separate power supply for the high power module? Ii think that will be necessary.

boshkash1151: STATUS = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0 RX_ADDR_P0-1 = 0xccccccccc3 0xcccccccc3c RX_ADDR_P2-5 = 0x33 0xce 0x3e 0xe3 TX_ADDR = 0xcccccccee3 RX_PW_P0-6 = 0x20 0x20 0x20 0x20 0x20 0x20 EN_AA = 0x3e EN_RXADDR = 0x3f RF_CH = 0x5a RF_SETUP = 0x21 CONFIG = 0x0f DYNPD/FEATURE = 0x3f 0x04 Data Rate = 250KBPS Model = nRF24L01+ CRC Length = 16 bits PA Power = PA_MIN

That is not the output that your code produces, but from a very different setup.

boshkash1151: @Robin2,

I tried your code and it works only when i disable the autoack

Post the exact code that you uploaded to your nRF24s. I don't think my code will work without acknowledgements. Post an example of the output from both Arduinos

Which nRF24 was acting as Tx and which as Rx?

What happens when you swap them round?

Debugging wireless needs a very methodical approach.

...R

Hi Robin2 & Whandall,

Thanks a lot for your help I was able to make it work with ack when changing those as per Whandall advice

  radio.setPALevel(RF24_PA_MAX);          
  radio.setAddressWidth(5);                  
  radio.setDataRate(RF24_2MBPS);        
  radio.setCRCLength(RF24_CRC_16 );              
  radio.setAutoAck(true);

I will update the post with a short summary of all i have done along with the code in first post

Thanks again for all your help, effort and precious time :slight_smile:

Solution
Short summary : I wanted to communicate between the nrf of the built-in antenna (let it be unit A) with the nrf of the external antenna (let it be be unit B) (images below) using Arduino Nano. Here are all the actions I have performed:

  1. Added 10uF capacitors to both units A & B.
  2. Unit B nrf is powered with external power source (5V → Voltage Regulator (with caps) → unit B)
  3. Used short jumper cables
  4. Antenna of unit B should be attached.
  5. changed those flags on both nanos of units A&B
  radio.setPALevel(RF24_PA_MAX);          
  radio.setAddressWidth(5);                  
  radio.setDataRate(RF24_2MBPS);        
  radio.setCRCLength(RF24_CRC_16 );              
  radio.setAutoAck(true);
  1. full test code :
    Transmitter
#include "SPI.h"            
#include <RF24.h>    
#include <printf.h>       

RF24 radio(7, 8);  

uint8_t addr [] = {"ndo1"};
int a = 0;

void setup() {
 radio.begin(); 
 Serial.begin(9600);
 printf_begin();
 radio.setChannel(99); 
 radio.setPALevel(RF24_PA_MAX);          
 radio.setAddressWidth(5);                  
 radio.setDataRate(RF24_2MBPS);        
 radio.setCRCLength(RF24_CRC_16 );              
 radio.setAutoAck(true);                 
 radio.openWritingPipe(addr);      
 radio.setRetries(15, 2);                
 radio.setPayloadSize(sizeof(a));         
 radio.stopListening();   
 radio.powerUp();   
 radio.printDetails();          
 }
void loop() {
  a+=3;
  bool value =radio.write(&a, sizeof(a));
  Serial.print("Trying to write:");
  Serial.print(a);
  Serial.print("     ---->   Result:");
  Serial.println(value==true?"Success":"Failure");
 if (a > 7100) { a = 0 ;}
 delay(1000);
}

Receiver

#include <SPI.h>            
#include "RF24.h"           
#include <stdint.h>
//#include <Servo.h>
#include <printf.h>


//rf2401
RF24 radio(7, 8); 
int a = 0;
int channel=0;
uint8_t addr [] = {"ndo1"}; 
uint8_t pn = 1;

void setup() {
  radio.begin();
  Serial.begin(9600);
  printf_begin();

 radio.setChannel(99);
 radio.setPALevel(RF24_PA_MAX);
 radio.setAddressWidth(5);
 radio.setPayloadSize(sizeof(a)); 
 radio.setDataRate(RF24_2MBPS);
 radio.setCRCLength(RF24_CRC_16);
 radio.setAutoAck(true);
 radio.openReadingPipe(pn, addr); 
 radio.powerUp();
 radio.printDetails();
 radio.startListening();
}
int lastRecv=1;
int success=0;
int error=0;
void loop() {
  //radio.openReadingPipe(pn, addr);
  if (radio.available(&pn)) {
    radio.read(&a, sizeof(a));
    //radio.closeReadingPipe(1);
    Serial.print("Got:");
    Serial.println(a);   
    if (a-lastRecv <= 3)
    {
      success++;
    }
    else
    {
      error++;
    }
    lastRecv=a;
    Serial.print("Success Rate : ");
    Serial.print(success);
    Serial.print("/");
    Serial.print(success+error);
    Serial.print("    (");
    float x = (float(success) / float(success+error))*100.0;
    Serial.print(x);
    Serial.println("%)");
    
  }
  else  {
    Serial.println("NC");

  }

  delay(500);

}

boshkash1151: I will update the post with a short summary of all i have done along with the code in first post

For the future please don't update earlier posts as it makes a Thread very hard to follow. Just add a line with a link to the Reply where the solution is.

Good to hear you have a solution though I am not clear about what is now different. What were the settings that did not work?

I notice in the addition to your Original Post

  1. Antenna of unit B should be attached.

I do hope it was attached all the time during the previous 16 posts!

...R

Robin2: For the future please don't update earlier posts as it makes a Thread very hard to follow. Just add a line with a link to the Reply where the solution is.

Done. sorry for that i though it would make it easier for people who faces the same issue to find the solution in the first post.

Robin2: Good to hear you have a solution though I am not clear about what is now different. What were the settings that did not work?

Settings before: radio.setPALevel(RF24_PA_MIN); radio.setAddressWidth(4); radio.setDataRate(RF24_256); radio.setCRCLength(RF24_CRC_8); radio.setAutoAck(false); // this was the my issue and so to make things work i had to change to autoack.

Settings after radio.setPALevel(RF24_PA_MAX); radio.setAddressWidth(5); radio.setDataRate(RF24_2MBPS); radio.setCRCLength(RF24_CRC_16 ); radio.setAutoAck(true);

Robin2: I notice in the addition to your Original PostI do hope it was attached all the time during the previous 16 posts!

...R

It was attached all the time, capacitor was added, and short jumper cables were used. I added them to make a full solution for others to read. I read in another blog/post that a user had to remove the antenna to make things work, but another replied that it should be there for the power to go through the antenna instead of through the board. In short, i was just confirming a valid point

Thanks