Having trouble with my nrf24l01s

hello! i'm a newbie and i'm using two espwroom32 to communicate my nrf24l01 and i can't make them work, it's for a school project. i have the RF24 library up to date, i have tried multiple wirings and tried different codes, and the transmitter seems to not even get to send the data.

this is my code:

#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(4,5); ///(CE,CSN)

///NRF TRANSMISOR

long weight;

void setup(){
  Serial.begin(9600);
  radio.begin();
  radio.setChannel(5); //Channel (0...127)
  radio.setDataRate (RF24_1MBPS); //RF24_250KBPS, RF24_1MBPS, RF24_2MBPS
  radio.setPALevel (RF24_PA_HIGH); //RF24_PA_MIN=-18dBm, RF24_PA_LOW=-12
  radio.openWritingPipe (0x1234567890LL); //0x1234567890
}

void loop(){
  weight=13381;
  
  bool success = radio.write(&weight, sizeof(weight));
if(success){
    Serial.println("Data sent successfully");
} else {
    Serial.println("Failed to send data");
}

  delay(1000);
}
#include <RF24.h>
RF24 radio(D4,D5);

///NRF RECEPTOR

long weight;

void setup(){
  delay(1000);
  Serial.begin(9600);
  Serial.println("Setup");
  radio.begin();
  radio.setChannel(5); //Channel (0...127)
  radio.setDataRate (RF24_1MBPS); //RF24_250KBPS, RF24_1MBPS, RF24_2MBPS
  radio.setPALevel (RF24_PA_HIGH); //RF24_PA_MIN=-18dBm, RF24_PA_LOW=-12
  radio.openReadingPipe (1, 0x1234567890LL); 
  radio.startListening();
}

void loop(){
  if(radio.available()){
    radio.read(&weight, sizeof(weight));
    Serial.println(weight);
  }
}

this is the wiring i used, it's not the same esp32 that i'm using but i looked for an espwroom32 pinout. i'm using the nrf24l01 + PA LNA


image

i'm not even sure what the problem might be, i was thinking on putting a capacitor between the gnd and vcc of the nrf but i've seen people that don't need it.

also i'm using two esp32 right now for testing but i'm planning on using an arduino nano as transmitter and an esp32 for receiver too, since i want my esp to run a server and the nrf with my nano is going to send data from a gps module to the server. is it possible? is using esp and arduino different from using two arduinos? please help.

it is a good idea to check that the NRF24 initializes OK, e.g.

void setup() {
  Serial.begin(115200);
  delay(1000);
  Serial.println("ESP32 > NRF24L01 Receive text");
  radio.begin();
  if (radio.isChipConnected())
    Serial.println("Receiver NF24 connected to SPI");
  else {
    Serial.println("NF24 is NOT connected to SPI");
    while (1)
      ;
  }

can you give a link to the specific ESP32 module you are using

Yes, that's not a problem in principle. I have a similar setup running in a few places in my home, with e.g. an ATtiny microcontroller sending data to an ESP-based controller elsewhere in the house.

How do you determine this?
Note that if you're looking for the value of the 'success' boolean in your code, this will only be true if the message is delivered successfully to the receiving station, and the receiving station has delivered an ACK (acknowledgement) back to the sender, and the sender has received that ACK. This process happens automatically, but it does mean that if your radio.write function returns 'false', it still can mean any number of things. It does NOT necessarily mean that the sender failed to transmit the message.

arduinos 3.3V regulator is not powerful enough for such demanding modules

1 Like

is that code for the receiver NRF24l01? don't i need to check the transmitter first?

how can i supply it enough power current? i'm power supplying my esp32 with an usb right now for testing but i'm planning on putting a 3.7 battery and a step-up for power supply, and just plugging the nrf24 with the 3.3v pin of the esp32. is there a way to support the power consumption without another battery?

i tried other code. i'm getting weird symbols on the serial monitor. this is my code and this is my wiring

/*
* Arduino Wireless Communication Tutorial
*     Example 1 - Transmitter Code
*                
* by Dejan Nedelkovski, www.HowToMechatronics.com
* 
* Library: TMRh20/RF24, https://github.com/tmrh20/RF24/
*/

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

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

const byte address[] = "00001";

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

if (!radio.begin()) {
  Serial.println(F("radio hardware not responding!"));
  while (1) {} // hold program in infinite loop to prevent subsequent errors
}

  
  radio.setAutoAck(false);
  radio.setChannel(115);
  radio.setPALevel(RF24_PA_LOW);
  
  radio.openWritingPipe(address);
  
  radio.stopListening();
  radio.printPrettyDetails();
}

void loop() {
  Serial.println("Entered TX loop");
  delay(150);
  const char text[] = "Hello World";
  radio.write(&text, sizeof(text));
  delay(1000);
}
/*
* Arduino Wireless Communication Tutorial
*       Example 1 - Receiver Code
*                
* by Dejan Nedelkovski, www.HowToMechatronics.com
* 
* Library: TMRh20/RF24, https://github.com/tmrh20/RF24/
*/

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

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

const byte address[] = "00001";

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

if (!radio.begin()) {
  Serial.println(F("radio hardware not responding!"));
  while (1) {} // hold program in infinite loop to prevent subsequent errors
}

  
  radio.setAutoAck(false);
  radio.setChannel(115);
  radio.setPALevel(RF24_PA_LOW);
  
  radio.openReadingPipe(1, address);
  
  radio.startListening();
  radio.printPrettyDetails(); 
  bool result = radio.isChipConnected();
  Serial.println(result);

}

void loop() {
//Serial.println("in loop");
delay(1);
  if (radio.available()) {
    Serial.println("the radio is available");
    char value[32] = "";
    radio.read(&value, sizeof(value));
    Serial.println(value);
    delay(1);
    }
  }
  • GND - GND
  • 3V3 - VCC
  • P13 - CE
  • P14 – CSN
  • P18 – SCK
  • P23 - MOSI
  • P19 – MISO
  • IRQ – not connected

transmitter serial monitor

receiver serial monitor

bauds are matching with the code

how can i know the problem then? i tried setting the PA level to low since i have my modules close together, i tried switching the ports, and i always get "failed to send data". is there a way i should run the codes? first the transmitter and then the receiver or the other way. i've read that the reset button of the esp32 doesn't reset the nrfs, so i constantly disconnect the power supply too to reset them. i'm not getting why it's not working since my code is fairly simple

This is almost certainly due to either a connection problem between the processor board and the radio module or improper powering of the radio module (as has already been mentioned is a problem with your setup).

Most people are able to get nRF24L01 radios working by following this tutorial. Follow it exactly, including using the recommended version of the TMRh20 library:
https://forum.arduino.cc/t/simple-nrf24l01-2-4ghz-transceiver-demo/405123

Post #30 in that Thread contains a simple program for testing connectivity between the processor and the radio module. You should probably try that first.

i tried running that code, with that same version of the library, adapting the connection to my esps and configuring the CE pin as 4 and CSN as 5. i'm getting this error now. i get the same error with the code in post #30

with the updated library i can run the code but i still can't make the nrfs communicate. i get this with the code in post #30 and this with the transmitter code, the receiver code doesn't show anything
image
image

As above....use a decent power supply.
Arduino or whatever you use are NOT power supply units.

it is recommended that you have code in both transmitter and receiver to check that the NRF24 initializes OK

Don't post screenshots, they're very difficult to read on small mobile device screens!!! Plus, they can't be selected an copied. Post all error messages and Serial monitor output using code tags.

Post ALL the information in the Serial Monitor from running the code in Post #30. That's only part of what it should print.

i'm sorry. in the screenshots i've put that's all the data i've actually got when i ran the code with my esp32. i've tried plugging it with my arduino nano and run the code in post #30 and this is what i've got

f��f�fff�����f�������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

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

i tried using a nano as transmitter and an esp32 as receiver as i intended at first but still no luck, the transmitter's serial monitor displays a bunch of "Data Sent Message 0 Tx failed". i've soldered a capacitor across gnd and vcc as i've seen a lot of people recommend. it's not in my plans to use an external power supply other than my esp or my nano or buying the adapter and i've seen a few people having problems with those too. i have a 3.7 battery and a stepdown that i can use for testing though. i'm plugging the wires directly.

i tried using my 3.7 battery and my stepdown to power supply both nrfs and i'm finally getting something different, though i still have a few problems.

on the transmitter serial monitor (arduino nano):

SimpleTx Starting
Data Sent Message 0  Acknowledge received
Data Sent Message 1  Acknowledge received
Data Sent Message 2  Acknowledge received
Data Sent Message 3  Tx failed
Data Sent Message 3  Tx failed
Data Sent Message 3  Tx failed

and it goes on with message 3 tx failed

and on the receiver serial monitor:

Data received 
Data received 
Data received 
Data received 
Data received 
Data received 
Data received 
Data received 
Data received 
Data received 
Data received 
Data received 

though it looks like the communication stops after a few moments judging from what i'm getting on the transmitter side?

You can't, really. You can do the connection diagnostics as you've been instructed to do, in order to verify that the module is connected properly to the Arduino (ESP, etc.) Beyond that, it's a matter of diligently checking every possible cause.

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