I've been struggling with trying to pass a structure between an Arduino NANO and an M5Stack Core2 through Serial Comms.
I can get the structure to pass correctly between two Arduino UNOs or NANOs, but when I try to get it to use on my project between a NANO and the M5Stack Core2, it fails. (Serial comms passes strings just fine!)
I finally figured out that the sizeof the Structure is reported as 15 bytes on the NANO and 24 bytes on the M5Stack Core2.
I changed my declarations from:
byte to uint8_t
int to uint32_t
on the NANO and M5.
I do also have a double in the structure:
//Use the same struct for comms both ways!
struct AmpStruct {
uint8_t bMode;
uint16_t iBand;
double dVolts;
uint16_t iAmpTemp;
uint16_t iFanOutput;
uint16_t iFwdPower;
uint16_t iRefPower;
};
//Initialize the values to create the usable structure
AmpStruct AmpData = {0, 0, 0, 0, 0, 0, 0};
Can anyone tell me what the difference is? Is there a way to make the structure the same between the two? There has to be way to declare the variables so they take up the same number of bytes on the two platorms.
I do have the comms working by passing strings, but I'd like to use the Structure within the communications.
Sir Michael