How to Transmit/Receive Multiple Data with RA-02 LoRa SOLVED

kgray9:
Hi all!
I am trying to send/receive 4 integers with ra-02 and Arduino or ESP8266.

Be careful using structures.
If your Arduino is one such as an Arduino UNO, Pro Mini or Mega, then 32 bit microcontrollers such as ESP32 and DUE, wont decode the structure correctly.
I can point you at a library that allows you to build the LoRa packet to send like this;

LoRa.startWriteSXBuffer(0);
LoRa.writeUint16(voltage);  
LoRa.writeUint16(temperature);  
LoRa.endWriteSXBuffer();

The receiver then uses this to decode the received buffer;

LoRa.startReadSXBuffer(0);
voltage = LoRa.readUint16(); 
temperature = LoRa.readUint16();
LoRa.endReadSXBuffer();

If you want to send a strucrure then the library allows you to send an array\buffer directly like this;

LoRa.transmit(array, sizeof(array), ...............

The array can be a structure, character array or and array that you fill yourself with integers, floats etc.