Hello,
I’m starting with my first application and want to decode message from an existing sketch. (dust sensor)
The values are encoded this way:
float p25median = median(samples_p25, 10);
float p10median = median(samples_p10, 10);
// Encode float as int (20.98 becomes 2098)
int16_t p10int = round(p10median * 100);
int16_t p25int = round(p25median * 100);
// **********************
// TTN
// **********************
// Encode int as bytes
byte payload[8];
// sds011
payload[0] = highByte(p10int);
payload[1] = lowByte(p10int);
payload[2] = highByte(p25int);
payload[3] = lowByte(p25int);
// dht22
payload[4] = highByte(hint); // humidity
payload[5] = lowByte(hint);
payload[6] = highByte(tint); // temperature
payload[7] = lowByte(tint);
// send via TTN
debugSerial.println("Sending data to TTN...");
ttn.sendBytes(payload, sizeof(payload));
How can I convert this to Json Object?
Would like to have it in a format like: {“pm10”:19,“pm25”:18,“temperature”:16,“humidity”:74}
thanks for any help or example and regards,
Thomas