[SOLVED] Need some help setting up my Nrf24L01 modules

Hello everyone, I need some help in order to figure out whether I am missing something, or I have faulty hardware.

I would like to avoid doing a very long post, listing all the things I have tried and search for (I am new to Arduino, but I've been an open source developer for +15 years, I know about doing extensive research and experiments before asking :stuck_out_tongue: )

Hardware:

  • Adruino Mega 2560
  • Adruino Pro Mini
  • Nrf24L01
  • Nrf24L01-PA-LNA

The very first thing I tried, was to put the Nrf24L01 in the pro mini, and the more powerful PA-LNA in the Mega, and tried the nrf24_client and nrf24_server examples from the RadioHead library (https://www.engineer2you.com/2017/03/arduino-pro-mini-33v-nrf24l01.html). After trying and failing several combinations, I gave up.

Then, following Nrf24L01-2.4GHz-HowTo - ArduinoInfo I decided to give TMRh20 library a try. The provided examples were a bit more complex than RadioHead ones, but I was able to configure a sender on one side and a receiver on the other, however, absolutely no data going through...

My biggest issue is, that I only had these 2 nrf24 modules, and I am completely unable to find out if I am having issues sending, receiving, or both...

Finally, I found that the TMRh20 library has an example called "scanner", which will iterate over all possible 125 channels, and try to find a carrier on each of them. The beauty of this example is that I can test each module separatedly on their own, since not only I have a WiFi router working on channel 4 for 2.4GHz (2.427 GHz) but I also have all my neighbours with their own routers, sending on different channels as well...

Needless to say, I have the SPI pins properly connected, and the famous 10µF capacitor between the 3.3V and GND pins.

This is what I get printed in the serial console from the scanner example, when using the Nrf24L01 PA-LNA module:

18:17:46.370 -> 
18:17:46.370 -> 
RF24/examples/scanner/
18:17:46.403 -> STATUS = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
18:17:46.403 -> RX_ADDR_P0-1 = 0xe7e7e7e7e7 0xc2c2c2c2c2
18:17:46.403 -> RX_ADDR_P2-5 = 0xc3 0xc4 0xc5 0xc6
18:17:46.403 -> TX_ADDR = 0xe7e7e7e7e7
18:17:46.403 -> RX_PW_P0-6 = 0x00 0x00 0x00 0x00 0x00 0x00
18:17:46.403 -> EN_AA = 0x00
18:17:46.403 -> EN_RXADDR = 0x03
18:17:46.403 -> RF_CH = 0x4c
18:17:46.403 -> RF_SETUP = 0x0f
18:17:46.403 -> CONFIG = 0x0e
18:17:46.403 -> DYNPD/FEATURE = 0x00 0x00
18:17:46.436 -> Data Rate = 2MBPS
18:17:46.436 -> Model = nRF24L01+
18:17:46.436 -> CRC Length = 16 bits
18:17:46.436 -> PA Power = PA_MAX
18:17:46.436 -> 000000000000000011111111111111112222222222222222333333333333333344444444444444445555555555555555666666666666666677777777777777
18:17:46.436 -> 0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcd
18:17:54.600 -> 4544545443444668898766667676566768575665545567798aa876750006401000000000000000000000000000000000000000000000000000000000000000
18:18:02.796 -> 343454555445565635556564533434343433434343434545487665750003200000000000000000000000000000000000000000000000000000000000000000
18:18:10.959 -> 334343545344343434325454566656465454544343343546575454540003200000000000000000000000000000000000000000000000000000000000000000
18:18:19.121 -> 555454545434444534435543434546565554434334343434344343430004200000000000000000000000000000000000000000000000000000000000000000
18:18:27.324 -> 455565644434343432434343433434355666756464344455566443430003000000000000000000000000000000000000000000000000000000000000000000
18:18:35.487 -> 353354757766453433434343443434354443535566553434434344530005300000000000000000000000000000000000000000000000000000000000000000

And this is what I get, when using the Nrf24L01 module

18:13:40.202 -> 
18:13:40.202 -> 
RF24/examples/scanner/
18:13:40.235 -> STATUS = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
18:13:40.235 -> RX_ADDR_P0-1 = 0xe7e7e7e7e7 0xc2c2c2c2c2
18:13:40.235 -> RX_ADDR_P2-5 = 0xc3 0xc4 0xc5 0xc6
18:13:40.235 -> TX_ADDR = 0xe7e7e7e7e7
18:13:40.235 -> RX_PW_P0-6 = 0x00 0x00 0x00 0x00 0x00 0x00
18:13:40.235 -> EN_AA = 0x00
18:13:40.235 -> EN_RXADDR = 0x03
18:13:40.235 -> RF_CH = 0x4c
18:13:40.235 -> RF_SETUP = 0x0f
18:13:40.235 -> CONFIG = 0x0e
18:13:40.235 -> DYNPD/FEATURE = 0x00 0x00
18:13:40.268 -> Data Rate = 2MBPS
18:13:40.268 -> Model = nRF24L01+
18:13:40.268 -> CRC Length = 16 bits
18:13:40.268 -> PA Power = PA_MAX
18:13:40.268 -> 000000000000000011111111111111112222222222222222333333333333333344444444444444445555555555555555666666666666666677777777777777
18:13:40.268 -> 0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcd
18:13:48.431 -> 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
18:13:56.630 -> 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
18:14:04.813 -> 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
18:14:12.978 -> 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
18:14:21.142 -> 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

As can be seen with the PA-LNA module, from channel 00 until about 3f, I am getting signals, which I believe are the signals from WiFi routers.

Now, first question:
Am I assuming this correctly? is all of this data coming from WiFi routers?

Also, it is my understanding that I am able to properly read and configure the Nrf24L01 module, however there is no data being received at all... I already tried all possible combinations of PA Levels and Data rates, and still nothing... Does this mean that the module is defective?

Could it be that the Nrf24L01 and the Nrf24L01 PA-LNA have differences in how they should be used, configured, and whatnot?

Any help is greatly appreciated

Can you post the sketches with which you sent data from one to the other?

Well... as I said, I gave up in trying to send data from one module to the other, since I do not know if I am having issues on the sender side, on the receiver side, or on both...

The code I tried before giving up, are the basic examples from the RadioHead library, modified to use pins 8 and 10 for CE and CS:

nrf24_client:

// nrf24_client.pde
// -*- mode: C++ -*-
// Example sketch showing how to create a simple messageing client
// with the RH_NRF24 class. RH_NRF24 class does not provide for addressing or
// reliability, so you should only use RH_NRF24 if you do not need the higher
// level messaging abilities.
// It is designed to work with the other example nrf24_server.
// Tested on Uno with Sparkfun NRF25L01 module
// Tested on Anarduino Mini (http://www.anarduino.com/mini/) with RFM73 module
// Tested on Arduino Mega with Sparkfun WRL-00691 NRF25L01 module

#include <SPI.h>
#include <RH_NRF24.h>

// Singleton instance of the radio driver
RH_NRF24 nrf24(8, 10);
// RH_NRF24 nrf24(8, 7); // use this to be electrically compatible with Mirf
// RH_NRF24 nrf24(8, 10);// For Leonardo, need explicit SS pin
// RH_NRF24 nrf24(8, 7); // For RFM73 on Anarduino Mini

void setup() 
{
  Serial.begin(9600);
  while (!Serial) 
    ; // wait for serial port to connect. Needed for Leonardo only
  if (!nrf24.init())
    Serial.println("init failed");
  // Defaults after init are 2.402 GHz (channel 2), 2Mbps, 0dBm
  if (!nrf24.setChannel(1))
    Serial.println("setChannel failed");
  if (!nrf24.setRF(RH_NRF24::DataRate2Mbps, RH_NRF24::TransmitPower0dBm))
    Serial.println("setRF failed");    
}


void loop()
{
  Serial.println("Sending to nrf24_server");
  // Send a message to nrf24_server
  uint8_t data[] = "Hello World!";
  nrf24.send(data, sizeof(data));
  
  nrf24.waitPacketSent();
  // Now wait for a reply
  uint8_t buf[RH_NRF24_MAX_MESSAGE_LEN];
  uint8_t len = sizeof(buf);

  if (nrf24.waitAvailableTimeout(500))
  { 
    // Should be a reply message for us now   
    if (nrf24.recv(buf, &len))
    {
      Serial.print("got reply: ");
      Serial.println((char*)buf);
    }
    else
    {
      Serial.println("recv failed");
    }
  }
  else
  {
    Serial.println("No reply, is nrf24_server running?");
  }
  delay(400);
}

nrf24_server:

// nrf24_server.pde
// -*- mode: C++ -*-
// Example sketch showing how to create a simple messageing server
// with the RH_NRF24 class. RH_NRF24 class does not provide for addressing or
// reliability, so you should only use RH_NRF24  if you do not need the higher
// level messaging abilities.
// It is designed to work with the other example nrf24_client
// Tested on Uno with Sparkfun NRF25L01 module
// Tested on Anarduino Mini (http://www.anarduino.com/mini/) with RFM73 module
// Tested on Arduino Mega with Sparkfun WRL-00691 NRF25L01 module

#include <SPI.h>
#include <RH_NRF24.h>

// Singleton instance of the radio driver
RH_NRF24 nrf24(8, 10);
// RH_NRF24 nrf24(8, 7); // use this to be electrically compatible with Mirf
// RH_NRF24 nrf24(8, 10);// For Leonardo, need explicit SS pin
// RH_NRF24 nrf24(8, 7); // For RFM73 on Anarduino Mini

void setup() 
{
  Serial.begin(9600);
  while (!Serial) 
    ; // wait for serial port to connect. Needed for Leonardo only
  if (!nrf24.init())
    Serial.println("init failed");
  // Defaults after init are 2.402 GHz (channel 2), 2Mbps, 0dBm
  if (!nrf24.setChannel(1))
    Serial.println("setChannel failed");
  if (!nrf24.setRF(RH_NRF24::DataRate2Mbps, RH_NRF24::TransmitPower0dBm))
    Serial.println("setRF failed");    
}

void loop()
{
  if (nrf24.available())
  {
    // Should be a message for us now   
    uint8_t buf[RH_NRF24_MAX_MESSAGE_LEN];
    uint8_t len = sizeof(buf);
    if (nrf24.recv(buf, &len))
    {
//      NRF24::printBuffer("request: ", buf, len);
      Serial.print("got request: ");
      Serial.println((char*)buf);
      
      // Send a reply
      uint8_t data[] = "And hello back to you";
      nrf24.send(data, sizeof(data));
      nrf24.waitPacketSent();
      Serial.println("Sent a reply");
    }
    else
    {
      Serial.println("recv failed");
    }
  }
}

Now, the scanner code that, as far as I understand, made me realize that the PA-LNA module works, and the other one is broken (At least that's what I understand) is this:

/*
 Copyright (C) 2011 J. Coliz <maniacbug@ymail.com>

 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 version 2 as published by the Free Software Foundation.
 */

/**
 * Channel scanner
 *
 * Example to detect interference on the various channels available.
 * This is a good diagnostic tool to check whether you're picking a
 * good channel for your application.
 *
 * Inspired by cpixip.
 * See http://arduino.cc/forum/index.php/topic,54795.0.html
 */

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

//
// Hardware configuration
//

// Set up nRF24L01 radio on SPI bus plus pins 7 & 8

RF24 radio(8,10);

//
// Channel info
//

const uint8_t num_channels = 126;
uint8_t values[num_channels];

//
// Setup
//

void setup(void)
{
  //
  // Print preamble
  //

  Serial.begin(115200);
  printf_begin();
  Serial.println(F("\n\rRF24/examples/scanner/"));

  //
  // Setup and configure rf radio
  //

  radio.begin();
  radio.setAutoAck(false);
  // RF24_PA_MIN, RF24_PA_LOW, RF24_PA_HIGH and RF24_PA_MAX
  radio.setPALevel(RF24_PA_MAX);
  // RF24_250KBPS for 250kbs, RF24_1MBPS for 1Mbps, or RF24_2MBPS
  radio.setDataRate(RF24_2MBPS);

  // Get into standby mode
  radio.startListening();
  radio.stopListening();

  radio.printDetails();

  // Print out header, high then low digit
  int i = 0;
  while ( i < num_channels )
  {
    printf("%x",i>>4);
    ++i;
  }
  Serial.println();
  i = 0;
  while ( i < num_channels )
  {
    printf("%x",i&0xf);
    ++i;
  }
  Serial.println();
}

//
// Loop
//

const int num_reps = 100;

void loop(void)
{
  // Clear measurement values
  memset(values,0,sizeof(values));

  // Scan all channels num_reps times
  int rep_counter = num_reps;
  while (rep_counter--)
  {
    int i = num_channels;
    while (i--)
    {
      // Select this channel
      radio.setChannel(i);

      // Listen for a little
      radio.startListening();
      delayMicroseconds(128);
      radio.stopListening();

      // Did we get a carrier?
      if ( radio.testCarrier() ){
        ++values[i];
      }
    }
  }

  // Print out channel measurements, clamped to a single hex digit
  int i = 0;
  while ( i < num_channels )
  {
    printf("%x",min(0xf,values[i]));
    ++i;
  }
  Serial.println();
}

// vim:ai:cin:sts=2 sw=2 ft=cpp

I am burning this code in the Mega 2560, and trying with the PA-LNA module, and then disconnecting this module with the antenna and connecting the module without the external antenna. They produce the output I pasted in my first post

So... No one can tell me if my assumptions are correct and the module might be broken? Or am I missing something?

I just finished working with Nrf24l01 radios. I had trouble getting them to work but got through it in a few days.

I got them to work with at commands but the tmrh20 library worked wonders for me.

Did you manage to communicate with them via the serial monitor?

BTW I used this tutorial :

Sorry about the serial monitor suggestion, that's from a cnc shield module not the nrf. Are you powering it from a stable 3.3v source?

Yep, I am able to communicate with the chips, as I shown in my first message... I am able to both configure and read the chip registry, for both modules. What I believe I am having trouble is making the one that doesn't have the external antenna to actually send/receive RF signals...

I did try connecting directly to the 3.3v from the Mega, I tried with an external source, and also tried with the 10µF... the last one is the one with better results...

I cannot try right now, but I will try the tutorial you suggested and see what happens...

OK. I'll try my same setup with one of my Nrf24l01 La +Pna modules to see if it works.

If you are using a high-power nRF24 (with external antenna) make sure it has a good 3..3v power supply - an Arduino 3.3v pin cannot supply enough current. Even for the low power nRF24 modules the nano seems unable to supply enough 3.3v current, and neither can my Mega clone. A pair of AA alkaline cells (3v) works well, at least for testing. Connect the battery GND to the Arduino GND.

Also, if you are using a high-power module make sure it is some distance from the other nRF24 - perhaps 3 metres - so that the high-power signal does not overwhelm the other.

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.

...R

Thank you Robin2, I will try your examples when I have some spare time and report back...

Let me ask you, since it seems you have plenty of experience with these modules... I have not seen power issues... I am experimenting with both modules by plugging and unplugging them from my Arduino Mega, and in the case of the high power nRF24 (The one with the external antenna), I am able to both read and configure the chip, as well as receive data (Using the "scanner" example from the TMRh20 library).

However, on the low power nRF24 module (The one without external antenna), I am able to configure and read the chip config, but it doesn't receive any data...

Have you seen problems related to power where the chip would be working just fine, but there is no data going in or out? I would guess that if there are power issues, I wouldn't be able to even read the chip config...

Wireless problems can be very difficult to debug. If the available 3.3v current is low it is more likely to present a problem when transmitting.

Have you some spare nRF24 modules in case one of them is faulty?

...R

Not right now, I already ordered 5 more... I'll do more tests when they arrive

Happy to report that I received a bunch of new modules, and I was able to confirm that the one I was using was defective...

After replacing them, the scanner example worked the same for all the new modules, and I was even able to use the other examples from the TMRh20 library to transfer data back and forth between the Mega and the Pro Mini.

Thanks all !!

frapell:
Happy to report that I received a bunch of new modules, and I was able to confirm that the one I was using was defective...

That can be very frustrating. Good to hear you have it working.

...R