NRF24L01 PA PL (Bidirectional String)

Does anyone know or have a sketch that sends a string to another arduino (A), using NRF24L01 PA PL, and the other arduino (B) "responds" by sending another string?

Example:
Arduino A sends a "test" message to the Arduino B
Arduino B "answer" by sending an "OK" message to the Arduino A

I have an example that only sends msg, but not "answer".

Regads, Bruno.

Arduino A: Transmissor

//TRANSMISSOR
#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"

RF24 radio(9, 10);
const uint64_t pipe = 0xF0F0F0F0E1LL;
void setup()
{
radio.begin();
radio.setRetries(2, 5);
radio.openWritingPipe(pipe);
radio.stopListening();
 
}

void loop()
{ 
   
        // send to arduino B
        radio.openWritingPipe(pipe);
        radio.stopListening();
        const char text[32] = "TEST";
        radio.write(&text, sizeof(text));
        delay(200);
        
        // Receive from Arduino B
        radio.openReadingPipe(1, pipe);
        radio.startListening();
        char text2[32] = {0};
        radio.read(&text2, sizeof(text2));
        Serial.println(text2);
        delay(100);
    
}

RECEPTOR: ARDUINO B

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


RF24 radio(9, 10);
const uint64_t pipe = 0xF0F0F0F0E1LL;


void setup()
{
Serial.begin(9600);
radio.begin();
  radio.setRetries(2, 5);
  radio.openReadingPipe(1, pipe);
radio.startListening();
}

void loop()
{

  // Receiving Arduino A 
  if (radio.available())
 {
  char text[32] = {0};
  radio.read(&text, sizeof(text));
  Serial.println(text);
  delay(100);
 
    
      // Send to Arduino A
      radio.openWritingPipe(pipe);
      radio.stopListening();
      const char text2[32] = "TEST";
      radio.write(&text2, sizeof(text2));
      delay(100);
      radio.openReadingPipe(1, pipe);
      radio.startListening();
 }
}

Have a look at the second example in this Simple nRF24L01+ Tutorial

...R

Robin2:
Have a look at the second example in this Simple nRF24L01+ Tutorial

...R

Hello R, thanks for the reply. Unfortunately the link shows the error msg :frowning:

Br_italia:
Hello R, thanks for the reply. Unfortunately the link shows the error msg :frowning:

What error message? I just tried my link now and it worked as expected.

...R

Robin2:
What error message? I just tried my link now and it worked as expected.

...R

See the picture, it just does not work. :frowning:

Robin2:
What error message? I just tried my link now and it worked as expected.

...R

Can you send a print of the result in serial.monitor?

Tks !

Images from Reply #4 so we don't have to download them. See this Simple Image Guide

...R

Please don't post pictures of text - they are almost impossible to read. Just copy and paste the text.

I take it from your images that when you said "Unfortunately the link shows the error msg" what you really meant was that when you tried the program in my link there was a problem. Successful computer programming demands precision.

Have you tried the connection-test program in my tutorial to see if your Arduinos can successfully communicate with the nRF24 it is connected to?

...R