How to make sense of Struct data received from Arduino in RPi via NRF24?
-
Hi guys,
I know that for a simple transmission e.g. humidity and temperature, the Arduino can simply fit these into a float array and send it to the RPi.
The RPi can then execute the following code snippet to get the value:
DataBytes=8 receivedMessage=bytearray(DataBytes) radio.read(receivedMessage,radio.getDynamicPayloadSize()) data = struct.unpack('ff',receivedMessage) humidity=data[0] temperature=data[1]
Arduino snippet:
struct values{ char name[15]; float temp; float humi; float light; float soilMoist; float soilTemp; float gasSensor; float pirSensor; }; struct values DataToSend; DataToSend.temp=dht.ReadTemperature(); //continue storing data in DataToSend radio.write(&DataToSend,sizeof(DataToSend))
My question is now, how would I send this struct from the Arduino to the RPi with a similar method like the float array?