Transmit String with nRF24L01+ modules and Mirf Library

Hello everybody,
I'm asking for help about my project. I want to send a String from an first Arduino Board to a second Arduino Board using nRF24L01 modules and the Mirf Library. I don't know how to convert the array of bytes caught by the receiver to a String, and how to print it.

This is my program on the first (sender) :

#include <SPI.h>
#include <Mirf.h>
#include <nRF24L01.h>
#include <MirfHardwareSpiDriver.h>

String data;

void setup(){
  Serial.begin(9600);
  Mirf.spi = &MirfHardwareSpi;
  Mirf.init();
  Mirf.setRADDR((byte *)"pcard");
  Mirf.payload = sizeof(String);
  Mirf.config();
  Serial.println("Configuration terminé"); 
  Mirf.setTADDR((byte *)"drone");
  Serial.println("Configuration terminé"); 
}

void loop(){
  
    
  if(Serial.available()>0){
    data = Serial.readString();
    Serial.println("Bien recu : "+ data);
    Mirf.send((byte *) &data);
    
    while(Mirf.isSending()){
    }
    Serial.println("Finished sending");
    }
}

This is my code on the receiver :

#include <SPI.h>
#include <Mirf.h>
#include <nRF24L01.h>
#include <MirfHardwareSpiDriver.h>




void setup(){
  Serial.begin(9600);
  Mirf.spi = &MirfHardwareSpi;
  Mirf.init();
  Mirf.setRADDR((byte *)"drone");
  Mirf.payload = sizeof(String);
  Mirf.config();
  Serial.println("Configuration terminé"); 
  
}

void loop(){
  String data="";

  
  if(Mirf.dataReady()){    
    Mirf.getData((byte *) &data);
    Serial.println(data);
  }
}

Thanks for help :slight_smile:

If you need it in an array of bytes for transmitting over the transceiver, why bother with Strings in the first place? Just use char arrays (also known as strings)

Hum yes, i didn't think about that. I will try to test with **s**trings object.
Thanks you.

It's working ! Really thanks you, i couldn't find it alone !