NRF24L01+PA+LNA dont work (Arduino Nano & ELEGOO Mega2560 R3)

Hello,
I've been trying to get my NRF24L01+PA+LNA up and running for a few days now, but unfortunately it's not working. I already had it running once, but then tried to convert it from an arduino uno to an ELEGOO Mega2560 R3 and since then it doesn't work anymore. Also tried to build it back to the Arduino Uno but that doesn't work anymore either.
I would be very happy about help.

Transmitter

  • Arduino Nano

  • PINS

* GND - GND
* VCC - 5V
* CE - PIN7
* CSN  - PIN8
* SCK - PIN13
* MOSI - PIN11
* MISO - PIN12
  • Code
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

RF24 radio(7, 8); // CE, CSN

const byte address[6] = "00001";

void setup() {
  Serial.begin(9600);
  radio.begin();
  radio.openWritingPipe(address);
  radio.setPALevel(RF24_PA_MIN);
  radio.stopListening();
}

void loop() {
  const char text[] = "Hello World";
  bool res = radio.write(&text, sizeof(text));
  if(res) {
    Serial.println("SUCCESS");
  } else {
    Serial.println("FAILED");
  }
  delay(1000);
}

Receiver

  • ELEGOO Mega2560 R3

  • PINS

* GND - GND
* VCC - 5V
* CE - PIN7
* CSN  - PIN8
* SCK - PIN52
* MOSI - PIN50
* MISO - PIN51
  • Code
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

RF24 radio(7,8);

const byte address[6] = "00001";

void setup() {
  Serial.begin(9600);
  radio.begin();
  radio.openReadingPipe(0,address);
  radio.setPALevel(RF24_PA_MAX);
  radio.setDataRate(RF24_250KBPS);
  radio.startListening();

  Serial.println("DEBUG 1");
}

void loop() {

  byte data[1];
  
  if (radio.available()) {
    radio.read(&data, sizeof(data));
    Serial.println(data[0]);
  }
}

See the SPI reference.
MOSI is pin 51.
MISO is pin 50.

I used Robin2's simple rf24 tutorial to get my RF24 radios to work. Pay careful attention to the part about power requirements for the radios.

The high powered modules may need to be separated by a few meters to work.

1 Like

Thanks for the help.
I looked at it again and swapped the PINS.
I also read through the tutorial, but there I could not conclude anything new from it either.

Unfortunately it still does not work.

I thank you very much anyway.

Did you change the CE and CSN pins in the example code to match your setup?

How are the rf24 modules powered?

1 Like

Yes, my CE pins are both on PIN7 and CSN on PIN8. I use the 5V from the Arduino itself because I use the "Breadboard Breakout Adapter" and I read that it needs 5V.

image
Adapter like this? I make my own adapters just like that and they work very well. They provide the needed power.

1 Like

yes, thats the one I use

In Robin2's tutorial in reply #30 is the check connection test code. That code provides a way to test the electrical connection between the rf24 module and its attached processor (not wireless connection). It may be worth running the code on your Nano and Mega to check the physical connections.

1 Like

I will give it a try. Thanks for the help. :slight_smile:

Test with ELEGOO Mega2560

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

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

Test with Arduino Nano

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



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



It looks like the problem is with the Arduino Nano.

I replaced the Arduino nano with an Arduino uno and I got this result. So it looks like the problem is with the Arduino nano.

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

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 0xc2c2c2c2c2
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



But I tested my test communication script with the Uno and the Mega and it doesn't work either. :frowning:

I checked everything again today and rewired. Unfortunately, it still does not work. Would still appreciate any help.

In your original post, you have effectively configured a different data rate between the transmitter and the receiver since the default data rate is 1MBPS.

Find a reliable tutorial, such as the one mentioned in post #8, and copy its code exactly but adapting pin numbers if required.

The NRF24L01 modules such as the ones you are using, with the PA and antenna, can be extremely difficult to set up. I have a project on my desk at the moment with 2 of these and using a new ATTiny series. Soldering a 10uF capacitor directly across the power rails on the module helped most. Unscrewing the antennas and lowering the transmission power to its minimum could also help.

In my case, since I have also the non-PA modules, I was able to rule out a configuration problem quite quickly.

Here is code that I tested on an Uno and a Mega. The code is modified from Robin2's simple RF24 tutorial. The code is compiled using the latest version of the RF24 library (installed from the IDE library manager). The code sends a incrementing integer from transmitter to receiver. I do not have the high power RF24 radio modules, so tested with regular ones.

Pins
Name      rf24        Uno         Mega
gnd       gnd         gnd         gnd
Vcc       Vcc          Vcc          Vcc
CE         3            7            7
CSN        4            8            8
SCK        5           13            52
MOSI       6           11            51
MISO       7           12            50
int        8           NC            NC

Transmitter (Uno):

// SimpleTx - the master or the transmitter

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


const byte CE_PIN = 7;
const byte CSN_PIN = 8;

const byte slaveAddress[5] = {'R', 'x', 'A', 'A', 'A'};


RF24 radio(CE_PIN, CSN_PIN); // Create a Radio

int dataToSend = 123;

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();
   //RF24_1MBPS, RF24_2MBPS, RF24_250KBPS
   radio.setDataRate( RF24_250KBPS );
   radio.setRetries(3, 5); // delay, count
   //radio.setChannel(10);
   //RF24_PA_MIN = 0,RF24_PA_LOW, RF24_PA_HIGH, RF24_PA_MAX
   radio.setPALevel(RF24_PA_LOW);
   radio.openWritingPipe(slaveAddress);
}

//====================

void loop()
{
   currentMillis = millis();
   if (currentMillis - prevMillis >= txIntervalMillis)
   {
      dataToSend++;
      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");
   }
   else
   {
      Serial.println("  Tx failed");
   }
}


Receiver (Mega):



// SimpleRx - the slave or the receiver

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

const byte CE_PIN = 7;
const byte CSN_PIN = 8;

const byte thisSlaveAddress[5] = {'R', 'x', 'A', 'A', 'A'};

RF24 radio(CE_PIN, CSN_PIN);

int recvData;

bool newData = false;

//===========

void setup()
{

   Serial.begin(9600);

   Serial.println("SimpleRx Starting");
   radio.begin();
   radio.setDataRate( RF24_250KBPS );
   radio.setRetries(3, 5); // delay, count
   radio.setPALevel(RF24_PA_LOW);
   radio.openReadingPipe(1, thisSlaveAddress);
   radio.startListening();
}

//=============

void loop()
{
   getData();
   showData();
}

//==============

void getData()
{
   if ( radio.available() )
   {
      radio.read( &recvData, sizeof(recvData) );
      newData = true;
   }
}

void showData()
{
   if (newData == true)
   {
      Serial.print("Data received >> ");
      Serial.print("number = ");
      Serial.println(recvData);
      
      newData = false;
   }
}

Thanks again for the help. Unfortunately this does not work either. I tried to recreate it exactly the same way, only I used the high power RF24 radio modules. The transmitter consistently gives "Tx failed". What does this mean/how to fix it?

Do you see anything on the serial console of the receiver ?
The message you got may only mean that the ack failed to get back from the receiver to the transmitter.

In the receiver console there is only the message "SimpleRx Starting". Nothing else.

Is it possible that one of the parts is simply broken? Even if the test from #8/#10 works?

It is, of course, always possible that one or both units is faulty in some subtle way

You can try these tests

  1. remove the screw-on antennas from both radios.
  2. comment out the following 2 statements on both the receiver and the transmitter
   radio.setDataRate( RF24_250KBPS );
   radio.setRetries(3, 5); // delay, count

Some models of the NRF24L01 don't support 250KBPS.
If that still fails, provide a good close up picture of your NRF24L01 modules.
However, then, the most likely cause is a power problem.

Unfortunately still does not work.