NRF24L01 PA/LNA does not transmit data

I´m trying to communicate between two ESP32´s using NRF24L01 PA/LNA. I only managed to transmit text which the maximum I got. The problem is that the module was only able to transmit the text right after reseting my esp32 and then always goes silent. I tried also the simplest code from Robin2´s simple tutorial but it was even worse and I didn´t get data transmitted. I also noticed when I upload codes in opposite(to my desired transmitter I upload receiver code and vice versa) it doesnt work at all. I use capacitor between 3.3V and GND.

My wiring:
3.3V - 3.3V GND - GND MISO - 19 MOSI - 23 SCK - 18 CE - 22 CSN - 21

Transmitter code:

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

RF24 radio(22, 21); // CE, CSN

void setup() {
  radio.begin();
  radio.disableCRC();
  radio.setAutoAck(true);
  radio.setDataRate(RF24_250KBPS);
  radio.openWritingPipe(0xF0F0F0E1LL);
  radio.setPALevel(RF24_PA_MAX);
  radio.stopListening();
}

void loop() {
  const String text = "bgfjds";
  radio.write(&text, sizeof(text));
  delay(1000);
}

Receiver code:

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

RF24 radio(22, 21); // CE, CSN

void setup() {
  Serial.begin(115200);
  radio.begin();
  radio.disableCRC();
  radio.setAutoAck(true);
  radio.setDataRate(RF24_250KBPS);
  radio.openReadingPipe(1, 0xF0F0F0E1LL);
  radio.startListening();
  
}

void loop() {
  if (radio.available()) {
    String text="";
    radio.read(&text, sizeof(text));
    Serial.println(text);
  }
}

You will only transmit the descriptor (length, start, ) and not the data.
Likewise, the receiver will receive a bogus pointer, which could even crash the ESP.

  const char text[] = "bgfjds";
  radio.write(&text, sizeof(text));

would work better, if the receiver code is adjusted also.

Some programmers even care whether their transmissions worked, but hey, it's your code.

Do not power the radios with the ESP32, use a separate


power supply as shown in your post. The grounds must be connected.

I tried to modify both transmitter and receiver code but its not working. Also the posted code stopped working. The nrf24 modules should be fine I also bought new one but it didnt fix the issue.

Please take a look at RF24/COMMON_ISSUES.md at master · nRF24/RF24 · GitHub

I also modified your code slightly, you just need to set the correct CE and CS pins in RF24 radio()

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

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

void setup() {
  radio.begin();
  radio.setAutoAck(true); // CRC has to be enabled if AA is enabled
  radio.setDataRate(RF24_250KBPS);
  radio.openWritingPipe(0xCCCECCCECCLL);  // Radio uses 5-byte address space
  radio.setPALevel(RF24_PA_MIN,0);  // Set PA level to min and disable LNA
  radio.stopListening();
}

void loop() {
  char text[] = "bgfjds";
  radio.write(&text, sizeof(text));
  delay(1000);
}
#include <SPI.h>
#include <RF24.h>

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

void setup() {
  Serial.begin(115200);
  radio.begin();
  radio.setAutoAck(true);  // CRC has to be enabled if AA is enabled
  radio.setDataRate(RF24_250KBPS);
  radio.openReadingPipe(1, 0xCCCECCCECCLL); //Radio uses 5-byte address space
  radio.setPALevel(RF24_PA_MIN,0);  // Set PA level to min and disable LNA
  radio.startListening();
  
}

void loop() {
  if (radio.available()) {
    char text[32];
    radio.read(&text, sizeof(text));
    Serial.println(text);
  }
}

The code works fine, so if you are still not having any luck with this, I would suggest power supply issues per the common issues doc.

Using pins 7 and 8 causes esp32 to crash(because they are connected to flash memory) but i tried many different pins so i´ll have to try using external power supply

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