Problem with NRF24L01+ Bi-directional communication

Hi, I want to make bi-directional communication between my Boat(UNO) and my Remote Control(MEGA 2560) with two NRF24L01+.

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(48, 53); // CE, CSN                                          
const byte addresses[][6] = {"00001", "00002"};
void setup() {
  Serial.begin(9600);
  pinMode(53, OUTPUT);
  radio.begin();
  radio.openWritingPipe(addresses[0]); // 00002
  radio.openReadingPipe(1, addresses[1]); // 00001
  radio.setPALevel(RF24_PA_MIN);
  
}
void loop() {
  delay(5);
  radio.startListening();
  if ( radio.available()) {
    while (radio.available()) {
    char text[32] = "";
    radio.read(&text, sizeof(text));  // Recieve "text" from Boat.
    Serial.println(text);    
    }
    delay(5);
    radio.stopListening();
    const char texted[] = "Hello from Remote Control";  // Sends "texted" to Boat.
    radio.write(&texted, sizeof(texted));
    
  }
}

The code above is for my Remote Control (with MEGA 2560 board). I want my Remote Control to send "Hello from Remote Control" and also receive another text from the Boat.

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

RF24 radio(7, 8); // CE, CSN
const byte addresses[][6] = {"00001", "00002"};

void setup() {
 
  Serial.begin(9600);
  radio.begin();
  radio.openWritingPipe(addresses[1]); // 00001
  radio.openReadingPipe(1, addresses[0]); // 00002
  radio.setPALevel(RF24_PA_MIN);
}
void loop() {
  delay(5);
  radio.stopListening();
  const char text[] = "Hello from Boat";  
  radio.write(&text, sizeof(text));  //Sends "text" to Remote Control
  delay(5);
  radio.startListening();
  while (!radio.available());
  char texted[32] = "";
  radio.read(&texted, sizeof(texted));  //Recieve "texted" from Remote Control
  Serial.println(texted);
  
}

The code above is for my Boat (with UNO board). I want to send "Hello from Boat" to my Remote Control and also receive another text from the Remote Control.

However, only my Remote Control receive a text from Boat when I plug the Remote Control USB to my laptop for serial monitor (meaning that my Boat is powered via battery and its USB is not connected to anything).

So, can anyone help me check if my codes are correct for what I want my Boat and RemoteControl to do. Which is to send a text to each other and receive a text from each other.

Edit: The two attachments I put, "remmote.png" and "Boatt.png" are the screenshots of the serial monitors for my Remote Control and Boat respectively.

And also for the pins connections:

  • Boat (with UNO board), from NRF24L01+:
    VCC > 5V , I'm using an adapter module for the transceiver.
    GND > GND
    CE > D7
    CSN > D8
    SCK > D13
    MOSI > D11
    MISO > D12

  • Remote Control (with MEGA 2560 board):
    VCC > 5V
    GND > GND
    CE > D48
    CSN > D53
    SCK > D52
    MOSI > D51
    MISO > D50

Have a look at this Simple nRF24L01+ Tutorial. The examples do work. I use the system in the second example for remote control for model trains.

You can make your pictures visible with this Simple Image Guide. However it is not a good idea to post pictures of text. Copy and Paste is better for text.

...R

Alright, I'll give that a try.

By the way, what do you mean when you said that?

However it is not a good idea to post pictures of text. Copy and Paste is better for text.

Am I supposed to copy and paste the words from the serial monitor to here?


Yes, copy to the scratch pad. Then post a reply. See the very first item above the text is "</>". Click on that and the cursor will be automatically positioned for you to copy what is on the scratch pad. On a PC, use ctrl-c. And your code will go right to proper place.

Paul

Yeah I got that. Thanks!