Sending multiple variable array over RF Link NRF24L01

Hi,

I am using an NRF24L01 and wish to send 3 variables (Temp, Humidity, Tank level) from sensor (UNO) to my reciever (MEGA). I have test code working sending “Hello world” and getting a response back so all is good with my RF link and comms.

I am trying to modify the script to allow me to send multiple variables however my knowledge of C is a little lacking, any guidance would be appreciated. Have made changes which I thought would work but get the below error message.

Tx code
“error: array must be initialized with a brace-enclosed initializer” on the line uint8_t data[1] = Temp;

// nrf24_client.pde
// -*- mode: C++ -*-
// Example sketch showing how to create a simple messageing client
// with the RH_NRF24 class. RH_NRF24 class does not provide for addressing or
// reliability, so you should only use RH_NRF24 if you do not need the higher
// level messaging abilities.
// It is designed to work with the other example nrf24_server.
// Tested on Uno with Sparkfun NRF25L01 module
// Tested on Anarduino Mini (http://www.anarduino.com/mini/) with RFM73 module
// Tested on Arduino Mega with Sparkfun WRL-00691 NRF25L01 module

#include <SPI.h>
#include <RH_NRF24.h>

int Temp = 10;		// setting test values
int Humidity = 20;	// setting test values
int Level =30;		// setting test values
int data[3];

// Singleton instance of the radio driver
RH_NRF24 nrf24;
// RH_NRF24 nrf24(8, 7); // use this to be electrically compatible with Mirf
// RH_NRF24 nrf24(8, 10);// For Leonardo, need explicit SS pin
// RH_NRF24 nrf24(8, 7); // For RFM73 on Anarduino Mini

void setup() 
{
  Serial.begin(9600);
  while (!Serial) 
    ; // wait for serial port to connect. Needed for Leonardo only
  if (!nrf24.init())
    Serial.println("init failed");
  // Defaults after init are 2.402 GHz (channel 2), 2Mbps, 0dBm
  if (!nrf24.setChannel(1))
    Serial.println("setChannel failed");
  if (!nrf24.setRF(RH_NRF24::DataRate2Mbps, RH_NRF24::TransmitPower0dBm))
    Serial.println("setRF failed");    
}


void loop()
{
  
  // Send message 
  
uint8_t data[1] = Temp;
uint8_t data[2] = Humidity;
uint8_t data[3] = Level;
  
  //uint8_t data[] = "Hello World!";  // This option works
  nrf24.send(data, sizeof(data));

  Serial.println("Sending.....");
  Serial.println(data[1]);
  Serial.println(data[2]);
  Serial.println(data[3]);
  
  nrf24.waitPacketSent();
  // Now wait for a reply
  uint8_t buf[RH_NRF24_MAX_MESSAGE_LEN];
  uint8_t len = sizeof(buf);

  if (nrf24.waitAvailableTimeout(500))
  { 
    // Should be a reply message for us now   
    if (nrf24.recv(buf, &len))
    {
      Serial.print("got reply: ");
      Serial.println((char*)buf);
    }
    else
    {
      Serial.println("recv failed");
    }
  }
  else
  {
    Serial.println("No reply, is nrf24_server running?");
  }
  delay(400);
}

Rx Code…

// nrf24_server.pde
// -*- mode: C++ -*-
// Example sketch showing how to create a simple messageing server
// with the RH_NRF24 class. RH_NRF24 class does not provide for addressing or
// reliability, so you should only use RH_NRF24  if you do not need the higher
// level messaging abilities.
// It is designed to work with the other example nrf24_client
// Tested on Uno with Sparkfun NRF25L01 module
// Tested on Anarduino Mini (http://www.anarduino.com/mini/) with RFM73 module
// Tested on Arduino Mega with Sparkfun WRL-00691 NRF25L01 module

#include <SPI.h>
#include <RH_NRF24.h>

// Singleton instance of the radio driver
RH_NRF24 nrf24(8, 53); //mega
//RH_NRF24 nrf24;
// RH_NRF24 nrf24(8, 7); // use this to be electrically compatible with Mirf
// RH_NRF24 nrf24(8, 10);// For Leonardo, need explicit SS pin
// RH_NRF24 nrf24(8, 7); // For RFM73 on Anarduino Mini

int buf[3];
int Temp = 0;
int Humidity = 0;
int Level = 0;

void setup() 
{
  Serial.begin(9600);
  while (!Serial) 
    ; // wait for serial port to connect. Needed for Leonardo only
  if (!nrf24.init())
    Serial.println("init failed");
  // Defaults after init are 2.402 GHz (channel 2), 2Mbps, 0dBm
  if (!nrf24.setChannel(1))
    Serial.println("setChannel failed");
  if (!nrf24.setRF(RH_NRF24::DataRate2Mbps, RH_NRF24::TransmitPower0dBm))
    Serial.println("setRF failed");    
}

void loop()
{
  if (nrf24.available())
  {
    // Should be a message for us now   
    uint8_t buf[RH_NRF24_MAX_MESSAGE_LEN];
    uint8_t len = sizeof(buf);
    if (nrf24.recv(buf, &len))
    {
//      NRF24::printBuffer("request: ", buf, len);
      Temp = buf[1];
      Humidity = buf[2];
      Level = buf[3];
      Serial.print("Temp: ");
      Serial.println((char*)buf[1]);
      Serial.print("Humidity: ");
      Serial.println((char*)buf[2]);
      Serial.print("Level: ");
      Serial.println((char*)buf[3]);
      
      // Send a reply
      uint8_t data[] = "Data Recieved";
      nrf24.send(data, sizeof(data));
      nrf24.waitPacketSent();
      Serial.println("Sent a reply");
    }
    else
    {
      Serial.println("recv failed");
    }
  }
}

I think this

uint8_t data[1] = Temp;
uint8_t data[2] = Humidity;
uint8_t data[3] = Level;

  //uint8_t data[] = "Hello World!";  // This option works

needs to be

uint8_t data[3]; // defines size of array
data[0] = Temp;  // puts the value from the variable Temp into the first element 
                            // note elements numbered from 0
                            // also assumes that Temp is defined as uint8_t or byte
data[1] = Humidity;
data[2] = Level;

  //uint8_t data[] = "Hello World!";  // This option works

and the code in the RX program must be the same

I am not familiar with the library you are using. I have used the TMRh20 version of the RF24 library.

...R Simple nRF24L01+ Tutorial

Thank you, that allows the sketcch to compile now!

However, the reciever just displays all blank data, I have receiver code as follows…

// nrf24_server.pde
// -*- mode: C++ -*-
// Example sketch showing how to create a simple messageing server
// with the RH_NRF24 class. RH_NRF24 class does not provide for addressing or
// reliability, so you should only use RH_NRF24  if you do not need the higher
// level messaging abilities.
// It is designed to work with the other example nrf24_client
// Tested on Uno with Sparkfun NRF25L01 module
// Tested on Anarduino Mini (http://www.anarduino.com/mini/) with RFM73 module
// Tested on Arduino Mega with Sparkfun WRL-00691 NRF25L01 module

#include <SPI.h>
#include <RH_NRF24.h>

// Singleton instance of the radio driver
RH_NRF24 nrf24(8, 53); //mega
//RH_NRF24 nrf24;
// RH_NRF24 nrf24(8, 7); // use this to be electrically compatible with Mirf
// RH_NRF24 nrf24(8, 10);// For Leonardo, need explicit SS pin
// RH_NRF24 nrf24(8, 7); // For RFM73 on Anarduino Mini

int buf[3];
int Temp = 0;
int Humidity = 0;
int Level = 0;

void setup() 
{
  Serial.begin(9600);
  while (!Serial) 
    ; // wait for serial port to connect. Needed for Leonardo only
  if (!nrf24.init())
    Serial.println("init failed");
  // Defaults after init are 2.402 GHz (channel 2), 2Mbps, 0dBm
  if (!nrf24.setChannel(1))
    Serial.println("setChannel failed");
  if (!nrf24.setRF(RH_NRF24::DataRate2Mbps, RH_NRF24::TransmitPower0dBm))
    Serial.println("setRF failed");    
}

void loop()
{ 
  if (nrf24.available())
  {
    // Should be a message for us now   
    uint8_t buf[RH_NRF24_MAX_MESSAGE_LEN];
    uint8_t len = sizeof(buf);
    if (nrf24.recv(buf, &len))
    {
//      NRF24::printBuffer("request: ", buf, len);
      Temp = buf[0];
      Humidity = buf[1];
      Level = buf[2];
      Serial.print("Temp: ");
      Serial.println((char*)buf[0]);
      Serial.print("Humidity: ");
      Serial.println((char*)buf[1]);
      Serial.print("Level: ");
      Serial.println((char*)buf[2]);
      
      // Send a reply
      uint8_t data[] = "Data Recieved";
      nrf24.send(data, sizeof(data));
      nrf24.waitPacketSent();
      Serial.println("Sent a reply");
    }
    else
    {
      Serial.println("recv failed");
    }
  }
}

You always need to post BOTH programs.

This

int buf[3];

is not the same as

uint8_t data[3];

A uint8_t is the same as a byte. An int uses the space of 2 bytes.

...R

Same result.
(The sending serial display shows corrcet data going out)

TX Code

// nrf24_client.pde
// -*- mode: C++ -*-
// Example sketch showing how to create a simple messageing client
// with the RH_NRF24 class. RH_NRF24 class does not provide for 

addressing or
// reliability, so you should only use RH_NRF24 if you do not need the 

higher
// level messaging abilities.
// It is designed to work with the other example nrf24_server.
// Tested on Uno with Sparkfun NRF25L01 module
// Tested on Anarduino Mini (http://www.anarduino.com/mini/) with RFM73 

module
// Tested on Arduino Mega with Sparkfun WRL-00691 NRF25L01 module

#include <SPI.h>
#include <RH_NRF24.h>

int Temp = 10;
int Humidity = 20;
int Level =30;
int data[3];

// Singleton instance of the radio driver
RH_NRF24 nrf24;
// RH_NRF24 nrf24(8, 7); // use this to be electrically compatible with 

Mirf
// RH_NRF24 nrf24(8, 10);// For Leonardo, need explicit SS pin
// RH_NRF24 nrf24(8, 7); // For RFM73 on Anarduino Mini

void setup() 
{
  Serial.begin(9600);
  while (!Serial) 
    ; // wait for serial port to connect. Needed for Leonardo only
  if (!nrf24.init())
    Serial.println("init failed");
  // Defaults after init are 2.402 GHz (channel 2), 2Mbps, 0dBm
  if (!nrf24.setChannel(1))
    Serial.println("setChannel failed");
  if (!nrf24.setRF(RH_NRF24::DataRate2Mbps, RH_NRF24::TransmitPower0dBm))
    Serial.println("setRF failed");    
}


void loop()
{
  
  // Send a message to nrf24_server
  
uint8_t data[3]; // defines size of array
data[0] = Temp;  // puts the value from the variable Temp into the first 

element
                            // note elements numbered from 0
                            // also assumes that Temp is defined as 

uint8_t or byte
data[1] = Humidity;
data[2] = Level;
   
  //uint8_t data[] = "Hello World!";  // THIS LINE WORKS
  nrf24.send(data, sizeof(data));

  Serial.println("Sending.....");
  Serial.println(data[0]);
  Serial.println(data[1]);
  Serial.println(data[2]);
  
  nrf24.waitPacketSent();
  // Now wait for a reply
  uint8_t buf[RH_NRF24_MAX_MESSAGE_LEN];
  uint8_t len = sizeof(buf);

  if (nrf24.waitAvailableTimeout(500))
  { 
    // Should be a reply message for us now   
    if (nrf24.recv(buf, &len))
    {
      Serial.print("got reply: ");
      Serial.println((char*)buf);
    }
    else
    {
      Serial.println("recv failed");
    }
  }
  else
  {
    Serial.println("No reply, is nrf24_server running?");
  }
  delay(400);
}

RX Code

// nrf24_server.pde
// -*- mode: C++ -*-
// Example sketch showing how to create a simple messageing server
// with the RH_NRF24 class. RH_NRF24 class does not provide for addressing or
// reliability, so you should only use RH_NRF24  if you do not need the higher
// level messaging abilities.
// It is designed to work with the other example nrf24_client
// Tested on Uno with Sparkfun NRF25L01 module
// Tested on Anarduino Mini (http://www.anarduino.com/mini/) with RFM73 module
// Tested on Arduino Mega with Sparkfun WRL-00691 NRF25L01 module

#include <SPI.h>
#include <RH_NRF24.h>

// Singleton instance of the radio driver
RH_NRF24 nrf24(8, 53); //mega
//RH_NRF24 nrf24;
// RH_NRF24 nrf24(8, 7); // use this to be electrically compatible with Mirf
// RH_NRF24 nrf24(8, 10);// For Leonardo, need explicit SS pin
// RH_NRF24 nrf24(8, 7); // For RFM73 on Anarduino Mini

uint8_t data[3];
int Temp = 0;
int Humidity = 0;
int Level = 0;
int watering = 1;

void setup() 
{
  Serial.begin(9600);
  while (!Serial) 
    ; // wait for serial port to connect. Needed for Leonardo only
  if (!nrf24.init())
    Serial.println("init failed");
  // Defaults after init are 2.402 GHz (channel 2), 2Mbps, 0dBm
  if (!nrf24.setChannel(1))
    Serial.println("setChannel failed");
  if (!nrf24.setRF(RH_NRF24::DataRate2Mbps, RH_NRF24::TransmitPower0dBm))
    Serial.println("setRF failed");    
}

void loop()
{ 
  if (nrf24.available())
  {
    // Should be a message for us now   
    uint8_t buf[RH_NRF24_MAX_MESSAGE_LEN];
    uint8_t len = sizeof(buf);
    if (nrf24.recv(buf, &len))
    {
//      NRF24::printBuffer("request: ", buf, len);
      Temp = buf[0];
      Humidity = buf[1];
      Level = buf[2];
      Serial.print("Temp: ");
      Serial.println((char*)buf[0]);
      Serial.print("Humidity: ");
      Serial.println((char*)buf[1]);
      Serial.print("Level: ");
      Serial.println((char*)buf[2]);
      
      // Send a reply

        uint8_t data[] = "yahoo";


      nrf24.send(data, sizeof(data));
      nrf24.waitPacketSent();
      Serial.println("Sent a reply");
    }
    else
    {
      Serial.println("recv failed");
    }
  }
}

You are still mixing up your data types.

In the TX program you have

uint8_t data[3];

but then you are trying to save 3 int variables into an array meant for three bytes.

I think the simple solution is to define the array as

int data[3];

as then it will match your other variables.

You need to read up about the different data types and the amount of memory each uses.

...R

Do yourself a favor and send/receive a struct ... by sending the data as binary, your sketches become very easy to modify in the future:

Thanks, Felix: RF69 send-receive struct examples

Ray

mrburnette: Do yourself a favor and send/receive a struct ...

That's not actually any advantage with an nRF24 if all the data items are of the same type and can be put into an array.

...R

Robin2:
I think the simple solution is to define the array as int data[3];

Thats how I tried it first of all but it gave errors, when I change it back to that i get the error message again:

error: no matching function for call to ‘RH_NRF24::send(int [3], unsigned int)’

nrf24.send(data, sizeof(data));

Tx Code

// nrf24_client.pde
// -*- mode: C++ -*-
// Example sketch showing how to create a simple messageing client
// with the RH_NRF24 class. RH_NRF24 class does not provide for addressing or
// reliability, so you should only use RH_NRF24 if you do not need the higher
// level messaging abilities.
// It is designed to work with the other example nrf24_server.
// Tested on Uno with Sparkfun NRF25L01 module
// Tested on Anarduino Mini (http://www.anarduino.com/mini/) with RFM73 module
// Tested on Arduino Mega with Sparkfun WRL-00691 NRF25L01 module

#include <SPI.h>
#include <RH_NRF24.h>

int Temp = 10;
int Humidity = 20;
int Level =30;

// Singleton instance of the radio driver
RH_NRF24 nrf24;
// RH_NRF24 nrf24(8, 7); // use this to be electrically compatible with Mirf
// RH_NRF24 nrf24(8, 10);// For Leonardo, need explicit SS pin
// RH_NRF24 nrf24(8, 7); // For RFM73 on Anarduino Mini

void setup() 
{
  Serial.begin(9600);
  while (!Serial) 
    ; // wait for serial port to connect. Needed for Leonardo only
  if (!nrf24.init())
    Serial.println("init failed");
  // Defaults after init are 2.402 GHz (channel 2), 2Mbps, 0dBm
  if (!nrf24.setChannel(1))
    Serial.println("setChannel failed");
  if (!nrf24.setRF(RH_NRF24::DataRate2Mbps, RH_NRF24::TransmitPower0dBm))
    Serial.println("setRF failed");    
}


void loop()
{
  
  // Send a message to nrf24_server
  
//uint8_t data[3]; // defines size of array
int data[3];
data[0] = Temp;  // puts the value from the variable Temp into the first element
                            // note elements numbered from 0
                            // also assumes that Temp is defined as uint8_t or byte
data[1] = Humidity;
data[2] = Level;
   
  //uint8_t data[] = "Hello World!";  // THIS LINE WORKS
  nrf24.send(data, sizeof(data));

  Serial.println("Sending.....");
  Serial.println(data[0]);
  Serial.println(data[1]);
  Serial.println(data[2]);
  
  nrf24.waitPacketSent();
  // Now wait for a reply
  uint8_t buf[RH_NRF24_MAX_MESSAGE_LEN];
  uint8_t len = sizeof(buf);

  if (nrf24.waitAvailableTimeout(500))
  { 
    // Should be a reply message for us now   
    if (nrf24.recv(buf, &len))
    {
      Serial.print("got reply: ");
      Serial.println((char*)buf);
    }
    else
    {
      Serial.println("recv failed");
    }
  }
  else
  {
    Serial.println("No reply, is nrf24_server running?");
  }
  delay(400);
}

dudester: error: no matching function for call to 'RH_NRF24::send(int [3], unsigned int)'

I don't recall your explaining that at the outset.

Try changing

nrf24.send(data, sizeof(data));

to

nrf24.send(&data, sizeof(data));

As I said I am only familiar with the TMRh20 version of the RF24 library

...R

that gives

error: no matching function for call to ‘RH_NRF24::send(int (*)[3], unsigned int)’

nrf24.send(&data, sizeof(data));

Should I use a different library?

// nrf24_client.pde
// -*- mode: C++ -*-
// Example sketch showing how to create a simple messageing client
// with the RH_NRF24 class. RH_NRF24 class does not provide for addressing or
// reliability, so you should only use RH_NRF24 if you do not need the higher
// level messaging abilities.
// It is designed to work with the other example nrf24_server.
// Tested on Uno with Sparkfun NRF25L01 module
// Tested on Anarduino Mini (http://www.anarduino.com/mini/) with RFM73 module
// Tested on Arduino Mega with Sparkfun WRL-00691 NRF25L01 module

#include <SPI.h>
#include <RH_NRF24.h>

int Temp = 10;
int Humidity = 20;
int Level =30;

// Singleton instance of the radio driver
RH_NRF24 nrf24;
// RH_NRF24 nrf24(8, 7); // use this to be electrically compatible with Mirf
// RH_NRF24 nrf24(8, 10);// For Leonardo, need explicit SS pin
// RH_NRF24 nrf24(8, 7); // For RFM73 on Anarduino Mini

void setup() 
{
  Serial.begin(9600);
  while (!Serial) 
    ; // wait for serial port to connect. Needed for Leonardo only
  if (!nrf24.init())
    Serial.println("init failed");
  // Defaults after init are 2.402 GHz (channel 2), 2Mbps, 0dBm
  if (!nrf24.setChannel(1))
    Serial.println("setChannel failed");
  if (!nrf24.setRF(RH_NRF24::DataRate2Mbps, RH_NRF24::TransmitPower0dBm))
    Serial.println("setRF failed");    
}


void loop()
{
  
  // Send a message to nrf24_server
  
//uint8_t data[3]; // defines size of array
int data[3];
data[0] = Temp;  // puts the value from the variable Temp into the first element
                            // note elements numbered from 0
                            // also assumes that Temp is defined as uint8_t or byte
data[1] = Humidity;
data[2] = Level;
   
  //uint8_t data[] = "Hello World!";  // THIS LINE WORKS
  nrf24.send(&data, sizeof(data));

  Serial.println("Sending.....");
  Serial.println(data[0]);
  Serial.println(data[1]);
  Serial.println(data[2]);
  
  nrf24.waitPacketSent();
  // Now wait for a reply
  uint8_t buf[RH_NRF24_MAX_MESSAGE_LEN];
  uint8_t len = sizeof(buf);

  if (nrf24.waitAvailableTimeout(500))
  { 
    // Should be a reply message for us now   
    if (nrf24.recv(buf, &len))
    {
      Serial.print("got reply: ");
      Serial.println((char*)buf);
    }
    else
    {
      Serial.println("recv failed");
    }
  }
  else
  {
    Serial.println("No reply, is nrf24_server running?");
  }
  delay(400);
}

dudester: Should I use a different library?

I do.

And sorry for being lazy but I am not proposing to also learn your library to figure out how to solve your problem

Try the examples in my Simple nRF24L01+ Tutorial

...R

Robin2: Try the examples in my Simple nRF24L01+ Tutorial

OK, started reading through those but it only specifies pin connections for a UNO, I am using a MEGA to Rx.

Maybe this Nrf24L01-2.4GHz-HowTo is useful.

Whandall: Maybe this Nrf24L01-2.4GHz-HowTo is useful.

Thanks.

Robin2:
Try the examples in my Simple nRF24L01+ Tutorial

Trying your tutorial 1
Txing UNO is just saying “Tx Failed”.
I have checked all wiring, it is correct.

// SimpleTx - the master or the transmitter

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


#define CE_PIN   9
#define CSN_PIN 10

const byte slaveAddress[5] = {'R','x','A','A','A'};


RF24 radio(CE_PIN, CSN_PIN); // Create a Radio

char dataToSend[10] = "Message 0";
char txNum = '0';


unsigned long currentMillis;
unsigned long prevMillis;
unsigned long txIntervalMillis = 1000; // send once per second


void setup() {

    Serial.begin(9600);

    Serial.println("SimpleTx Starting");

    radio.begin();
    radio.setDataRate( RF24_250KBPS );
    radio.setRetries(3,5); // delay, count
    radio.openWritingPipe(slaveAddress);
}

//====================

void loop() {
    currentMillis = millis();
    if (currentMillis - prevMillis >= txIntervalMillis) {
        send();
        prevMillis = millis();
    }
}

//====================

void send() {

    bool rslt;
    rslt = radio.write( &dataToSend, sizeof(dataToSend) );
        // Always use sizeof() as it gives the size as the number of bytes.
        // For example if dataToSend was an int sizeof() would correctly return 2

    Serial.print("Data Sent ");
    Serial.print(dataToSend);
    if (rslt) {
        Serial.println("  Acknowledge received");
        updateMessage();
    }
    else {
        Serial.println("  Tx failed");
    }
}

//================

void updateMessage() {
        // so you can see that new data is being sent
    txNum += 1;
    if (txNum > '9') {
        txNum = '0';
    }
    dataToSend[8] = txNum;
}

dudester: OK, started reading through those but it only specifies pin connections for a UNO, I am using a MEGA to Rx.

You just need to figure out the 3 SPI pins used by the Mega - I think they are 50, 51 and 52 (Miso, Mosi and SCK). The other two (CE and CSN) can be any I/O pins. pin 53 is SS and I presume (like the Uno) it should be set as OUTPUT to ensure the Mega acts as SPI master

...R

dudester: Trying your tutorial 1 Txing UNO is just saying "Tx Failed".

Without knowing what you are doing on the RX side I can't comment.

...R

Hi,

I have managed to get your ‘getting started’ tutorial working now, I had a few things wrong but all sorted. I have modified your code to send my 3 test variables as an array and this is now working too.
Thank you for your help.

My next step is to send back the status of a switch each time these 3 variables are recieved, just not sure how to add this… Is there a simpler way than duplicating all the code?

Tx Code

// SimpleTx - the master or the transmitter

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


#define CE_PIN   9
#define CSN_PIN 10

const byte slaveAddress[5] = {'R','x','A','A','A'};

RF24 radio(CE_PIN, CSN_PIN); // Create a Radio

int dataToSend[3];


void setup() {

    Serial.begin(9600);

    Serial.println("SimpleTx Starting");

    radio.begin();
    radio.setDataRate( RF24_250KBPS );
    radio.setRetries(3,5); // delay, count
    radio.openWritingPipe(slaveAddress);
}

//====================

void loop() {

        dataToSend[0] = 100;
        dataToSend[1] = 200;
        dataToSend[2] = 300;
        send();
}

//====================

void send() {

    bool rslt;
    rslt = radio.write( &dataToSend, sizeof(dataToSend) );
        // Always use sizeof() as it gives the size as the number of bytes.
        // For example if dataToSend was an int sizeof() would correctly return 2

    Serial.print("Data Sent ");
    Serial.print(dataToSend[0]);
    Serial.print(dataToSend[1]);
    Serial.print(dataToSend[2]);
    if (rslt) {
        Serial.println("  Acknowledge received");
        }
    else {
        Serial.println("  Tx failed");
    }
}

Rx Code

// SimpleRx - the slave or the receiver

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

#define CE_PIN   9
#define CSN_PIN 53

const byte thisSlaveAddress[5] = {'R','x','A','A','A'};

RF24 radio(CE_PIN, CSN_PIN);

int dataReceived[3]; // this must match dataToSend in the TX
bool newData = false;

//===========

void setup() {

    Serial.begin(9600);

    Serial.println("SimpleRx Starting");
    radio.begin();
    radio.setDataRate( RF24_250KBPS );
    radio.openReadingPipe(0, thisSlaveAddress);
    radio.startListening();
}

//=============

void loop() {
    getData();
    showData();
}

//==============

void getData() {
    if ( radio.available() ) {
        radio.read( &dataReceived, sizeof(dataReceived) );
        newData = true;
    }
}

void showData() {
    if (newData == true) {
        Serial.print("Data received ");
        Serial.println(dataReceived[0]);
        Serial.println(dataReceived[1]);
        Serial.println(dataReceived[2]);
        newData = false;
    }
}

The second example (which uses the ackPayload feature) is probably the simplest way to send back data.

...R PS, Thanks for confirming that my code works.