# Decoding byte payload

**URL:** <https://www.thethingsnetwork.org/forum/t/decoding-byte-payload/12944>\
**Category:** Application Development\
**Created:** [February 27, 2018, 4:48pm UTC](https://www.thethingsnetwork.org/forum/t/decoding-byte-payload/12944 "2018-02-27T16:48:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![thomaswa](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/thomaswa/32/48087_2.png) [@thomaswa](https://www.thethingsnetwork.org/forum/u/thomaswa)\
**Post date:** [February 27, 2018, 4:48pm UTC](https://www.thethingsnetwork.org/forum/t/decoding-byte-payload/12944/1 "2018-02-27T16:48:37Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![arjanvanb](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/arjanvanb/32/46626_2.png) [@arjanvanb](https://www.thethingsnetwork.org/forum/u/arjanvanb)\
**Post date:** [February 27, 2018, 5:26pm UTC](https://www.thethingsnetwork.org/forum/t/decoding-byte-payload/12944/2 "2018-02-27T17:26:42Z")

</div>

- [Is there any documentation on payload functions?](https://www.thethingsnetwork.org/forum/t/is-there-any-documentation-on-payload-functions/3441/3)
- [https://www.thethingsnetwork.org/docs/devices/bytes.html](https://www.thethingsnetwork.org/docs/devices/bytes.html)
