Good morning,
I have a projet of connected beehive. I want to follow the weight, the temperature and the humidity.
I use several sensors and I need to send data using 2 E220-400T30D Ebyte modules.
I can send a single value (for example the weight). I use the different examples in the librairy.
But I can't send all the value with an array.
Here is a part of my sender header :
#define ENABLE_RSSI true
#define RUCHER "Ruche1"
struct Message {
char ruche[10]; //ruche = beehive in english
float poids; //poids= weight in english
};
and in sender void loop
for (float poids=0; poids<100; poids++) //for the test, I increase manually the variable poids to simulate a weight variation. In reality the weight will come from a sensor.
{
struct Message msg = {RUCHER, poids}; // for the test I only try to send the name of my beehive "Ruche1" and the weight poids
// Send message
ResponseStatus rs = e220ttl.sendFixedMessage(0, 3, 23, &msg, sizeof(Message));
// Check If there is some problem of succesfully send
// Print the data send
Serial.print("Message Array length : ");Serial.println(sizeof(msg.ruche));
Serial.println(msg.ruche);
Serial.print("Poids Array length : ");Serial.println(sizeof(msg.poids));
Serial.println(msg.poids);
Serial.println(rs.getResponseDescription());
Serial.println(sizeof(Message));
delay(10000);
}
For the receiver, the header is the same
In receiver void loop I have the following code :
// Print the data received
Serial.println(rsc.status.getResponseDescription());
struct Message msg = *(Message*) rsc.data;
Serial.println(msg.ruche);
Serial.println(msg.poids);
Serial.println(sizeof(Message));
rsc.close();
And the result shown in serial monitor for the sender :
Message Array length : 10
Ruche1
Poids Array length : 4
2.00
Success
14
but in serial monitor for the receiver I have :
Message received! <——– my message is received
Success <——– success in transmission
<——– nothing but should be Ruche1
0.00 <——– 0.00 but should be 2.00
14
I don't understand why the value are not correctly received...
Is someone could help me please ?
Thank you very much
Damien