# How to Extract Negative value in Payload function

**URL:** <https://www.thethingsnetwork.org/forum/t/how-to-extract-negative-value-in-payload-function/8821>\
**Category:** Application Development\
**Created:** [August 5, 2017, 6:58am UTC](https://www.thethingsnetwork.org/forum/t/how-to-extract-negative-value-in-payload-function/8821 "2017-08-05T06:58:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ashi14](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/ashi14/32/7397_2.png) [@Ashi14](https://www.thethingsnetwork.org/forum/u/Ashi14)\
**Post date:** [August 5, 2017, 6:58am UTC](https://www.thethingsnetwork.org/forum/t/how-to-extract-negative-value-in-payload-function/8821/1 "2017-08-05T06:58:03Z")

</div>

Am trying to send negative temperature data from DB18B20 to TTN using Arduino LMIC, am able to send negative data, but **TTN decoder** is considering as un signed Int and changing the value from -3456 to 62080.

Please help me to decode Negative value in TTN decoder function.

Code at Arduino :

```
  int16_t temp5 = -3456; 
  Serial.print(" Dummy of 6th IC is: ");
  Serial.println(temp5);

  data[10] = temp5 >> 8;
  data[11] = temp5 & 0xFF;

```

Payload sent : temp5 = -3456

Decoder at TTN :

```
  var temp5 = (bytes[10] << 8)| bytes[11];

```

Payload receive and decoded at TTN = 62080

---

<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:** [August 5, 2017, 8:09am UTC](https://www.thethingsnetwork.org/forum/t/how-to-extract-negative-value-in-payload-function/8821/2 "2017-08-05T08:09:47Z")

</div>

See [Decrypting messages for dummies](https://www.thethingsnetwork.org/forum/t/decrypting-messages-for-dummies/4894/4) Or add some base value like 32,768 (the minimum value for a signed 16 bits integer) before sending, and subtract that again after decoding.
