Nrf24l01 communication problem

Hello
I use nrf24l01 PA + LNA modules with the RF24 library. I managed to make them interract ("the radio .available() function returns true and the reading loop begins normally but the message can not be displayed in the serial monitor. I would like to fix this problem of empty message. The codes below are some test codes, the initial project is to build an RC car and I'm currently working on the remote control system.

Emmission code :

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

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

void setup() {
  Serial.begin(9600);
  radio.begin();
  radio.openWritingPipe(0xF0F0F0F0E1LL);  // Adresse de transmission (5 octets)
}

void loop() {
  char message[] = "Hello, Receiver!";  // Message à envoyer  
  
  radio.write(&message, sizeof(message));  // Envoie le message

  Serial.println("Message envoyé : " + String(message));

  delay(1000);
}

Reception code :

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

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

void setup() {
  Serial.begin(9600);
  radio.begin();
  radio.openReadingPipe(1, 0xF0F0F0F0E1LL);  // Adresse de réception (5 octets)
  radio.startListening();
}

void loop() {
  if (radio.available()) {
    char message[32] = "";  // Tampon pour stocker le message reçu

    radio.read(message, sizeof(message));  // Lit le message reçu

    Serial.println("Message reçu : " + String(message));
  }
  delay(1000);
}

I've been struggling on this for the last month and I really could use some advice :grin:

Welcome to the forum

Serial.println("Message reçu : " + String(message));

Why are you converting the received message to a String before printing it ?

Try

    radio.read(message, sizeof(message));  // Lit le message reçu

    Serial.println("Message reçu : ");
    Serial.print(message);

Thanks !
The problem seems to be something else. When I plug the receptor alone, it still prints "Message reçu : " and nothing behind. I assume it receives a signal from another device. Is there a better channel than the one I am currently using ?

Start by trying the sketches in this topic

Simple nRF24L01+ 2.4GHz transceiver demo

Most problems that I have seen reported turn out to be caused by power supply problems. How are your RF24 modules powered ?

My arduino uno is plugged to my PC and the module is powered through the 3.3V pin and i added a 10000 microF condensator as suggested.

I tried the code in the tutorial you sent (excellent tutorial btw :slightly_smiling_face: ) the TX keeps failing to send while the RX displays "data recieved" at a very high rate. I tried to go outside to be far away from bluetooth and wi-fi but it did not help.

Did you try the connection test sketch and what were the results ?

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