Sending data via RadioHead library RF433 array/list

Im using the radiohead library and 433Mhz pair to send data from a nano to an UNO:

The Tx code is:

// Include RadioHead Amplitude Shift Keying Library
#include <RH_ASK.h>
// Include dependant SPI Library 
#include <SPI.h> 

//Define the object to access and cotrol the Gyro and Accelerometer (We don't use the Gyro data)
//MPU6050 mpu;
int16_t ax, ay, az;
int16_t gx, gy, gz;

//Define packet for the direction (X axis and Y axis)
int data[2];

// Create Amplitude Shift Keying Object
RH_ASK rf_driver;

void setup() {
  Serial.begin(9600);
  //mpu.initialize();              //Initialize the MPU object

  // Initialize ASK Object
  rf_driver.init();

}

void loop() {
  delay(2000);

  //With this function, the acceleration and gyro values of the axes are taken. 
  //If you want to control the car axis differently, you can change the axis name in the map command.
  //mpu.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
  
    //In two-way control, the X axis (data [0]) of the MPU6050 allows the robot to move forward and backward. 
  //Y axis (data [0]) allows the robot to right and left turn.
  data[0] = map(255, -17000, 17000, 300, 400 ); //Send aX axis data
  data[1] = map(333, -17000, 17000, 100, 200);  //Send aY axis data

   //I hardcoded the values 255 and 333 in order to test the data format...************************
  rf_driver.send((const uint8_t*)data, sizeof(data));
  rf_driver.waitPacketSent();
    
}

while the Rx code is:

// Include RadioHead Amplitude Shift Keying Library
#include <RH_ASK.h>
// Include dependant SPI Library 
#include <SPI.h> 

// Create Amplitude Shift Keying Object
RH_ASK rf_driver;

//Define packet for the direction (X axis and Y axis)
int data[2];

void setup() {
  Serial.begin(9600);
  rf_driver.init();

}

void loop() {
// Set buffer to size of expected message
    int receivedData[3] = {0};
    uint8_t buflen = sizeof(receivedData);
    if (rf_driver.recv((uint8_t*)receivedData, &buflen)) {
      //if data is not an array, use &receivedData
    for (byte i = 0; i < 3; i++) {
      Serial.print(receivedData[i]);
      Serial.print('\t');
      Serial.println(receivedData[i],HEX);
    }
  }


               
}

I understand I will have a value for data[0] and another for data[1] where the former is X-axis and the latter is y-axis. The map function takes the ax value, which occurs from -17,000 to +17,000 and maps it to a value between 300 and 400. ay is treated similarly to a value between 100-200. So in the end I will have:

data[0] = 350 maybe and
data[1] = 150 maybe.

the data is:

350 15E
150 96
0 0
350 15E
150 96
0 0
350 15E
150 96
0 0
350 15E
150 96
0 0

Isee that first its the dec value and then the hex value. Im guessing the author of that bit of code I borrowed from was using it just to ensure the received values, but what about the 0,0? Is there a usual reason to use this way of sending/receiving data for verification purposes maybe, or was it just coincidence it was used this way?

This is where I got it from:

Im guessing the hex was just because the OP in that question had actually sent/received data in different formats so maybe the responder was pointing out the hex to decimal conversion, but what about the 0,0 at the end?

    for (byte i = 0; i < 3; i++) {
      Serial.print(receivedData[i]);
      Serial.print('\t');
      Serial.println(receivedData[i],HEX);
    }

You sent how many bytes? I count 4.

You received how many bytes? Why don’t you know? The function told you how many!

That corresponds to some number of ints. You are not iterating the proper number of times.

Got it...the array was prefilled with 0?

    int receivedData[3] = {0};

Got it...the array was prefilled with 0?

No. You declared an array of length 3, but provided only one initial value. So, receivedData[ 0 ] was set to 0. You have no idea what is in receivedData[ 1 ] or receivedData[ 2 ].

Ok im not following the structure of this thing. Yes I do know what is in receivedData[ 1 ], because the for loop fills receivedData[0] with the value of 350 and receivedData[1] with the next value of 150.

I do this in code:

Tx

data[0]=350
data[1]=150

on the other side receivedData[3] array is declared, which I understand is 1 element ‘bigger’ than data was. When I read the data and put it into the receivedData array:

Rx

receivedData[0]=350
receivedData[1]=150
receivedData[2]= *since there is no more data to cycle thru in the data[] array that was received, it doesnt fill this slot, but somehow that slot has a value of 0.  So that is why I thought it might be prefilled with 0s.

on the other side receivedData[3] array is declared, which I understand is 1 element 'bigger' than data was.

It is. But, why? If you want to receive two bytes, you need a 2 element array to put them in.

receivedData[2]= *since there is no more data to cycle thru in the data[]
array that was received, it doesnt fill this slot, but somehow that slot has a value
of 0.  So that is why I thought it might be prefilled with 0s.

You need to put a period after the second line. The array occupies some location in memory that had some data in it. You might get lucky and find that the data is all 0s. Or, you might find that the data is a bunch of meaningless values.