# Heltec Cube Cell Decoder for BME680

**URL:** <https://www.thethingsnetwork.org/forum/t/heltec-cube-cell-decoder-for-bme680/33252>\
**Category:** End Devices (Nodes)\
**Created:** [January 9, 2020, 5:50am UTC](https://www.thethingsnetwork.org/forum/t/heltec-cube-cell-decoder-for-bme680/33252 "2020-01-09T05:50:50Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![christoph-laib](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/christoph-laib/32/41289_2.png) [@christoph-laib](https://www.thethingsnetwork.org/forum/u/christoph-laib)\
**Post date:** [January 9, 2020, 5:50am UTC](https://www.thethingsnetwork.org/forum/t/heltec-cube-cell-decoder-for-bme680/33252/1 "2020-01-09T05:50:50Z")

</div>

Hi there  
has anyone written a payload decoder BME680 for the Multisensor Example from Heltec ?

thanks a lot

---

<div class="post-metadata">

**Author:** ![obaeyens](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/obaeyens/32/25844_2.png) [@obaeyens](https://www.thethingsnetwork.org/forum/u/obaeyens)\
**Post date:** [January 9, 2020, 7:18pm UTC](https://www.thethingsnetwork.org/forum/t/heltec-cube-cell-decoder-for-bme680/33252/2 "2020-01-09T19:18:35Z")

</div>

You mean something like this:

```
function Decoder(bytes, port) {
  // Decode an uplink message from a buffer
  // (array) of bytes to an object of fields.
  var decoded = {};

  // if (port === 1) decoded.led = bytes[0];
  
  decoded.Temperature = (bytes[1] << 8) + bytes[0];
  decoded.Temperature=decoded.Temperature/100.0

  decoded.Pressure = (bytes[3] << 8) + bytes[2];
  decoded.Humidity = (bytes[5] << 8) + bytes[4];

  decoded.Humidity=decoded.Humidity/100.0
  return decoded;
}

```

This converts bytes “01 02 03 04 05 06” to 2 bytes = Temperature, next 2 bytes to Pressure and the final 2 bytes to Humidity.

Naming the return variables like decode.xxx wil return a json object that has this xxx=value.

---

<div class="post-metadata">

**Author:** ![obaeyens](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/obaeyens/32/25844_2.png) [@obaeyens](https://www.thethingsnetwork.org/forum/u/obaeyens)\
**Post date:** [January 9, 2020, 9:49pm UTC](https://www.thethingsnetwork.org/forum/t/heltec-cube-cell-decoder-for-bme680/33252/3 "2020-01-09T21:49:15Z")

</div>

I may have misunderstood the question.

Are you referring to the payload bytes sent from the sensor to the loRaWan gateway and to be decoded in your application?

Or are you referring how to read the sensor data on the Heltec Cube Cell Decoder and convert this to the LoRaWan payload to be transmitted?

---

<div class="post-metadata">

**Author:** ![christoph-laib](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/christoph-laib/32/41289_2.png) [@christoph-laib](https://www.thethingsnetwork.org/forum/u/christoph-laib)\
**Post date:** [January 10, 2020, 7:19am UTC](https://www.thethingsnetwork.org/forum/t/heltec-cube-cell-decoder-for-bme680/33252/4 "2020-01-10T07:19:42Z")

</div>

exactly 🙂

---

<div class="post-metadata">

**Author:** ![christoph-laib](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/christoph-laib/32/41289_2.png) [@christoph-laib](https://www.thethingsnetwork.org/forum/u/christoph-laib)\
**Post date:** [January 10, 2020, 7:21am UTC](https://www.thethingsnetwork.org/forum/t/heltec-cube-cell-decoder-for-bme680/33252/5 "2020-01-10T07:21:27Z")

</div>

i refer to the data sent by the cubecell to be decoded within the TTN

---

<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:** [January 10, 2020, 11:12am UTC](https://www.thethingsnetwork.org/forum/t/heltec-cube-cell-decoder-for-bme680/33252/6 "2020-01-10T11:12:20Z")

</div>

> [@obaeyens](#):
>
> ```javascript
> decoded.Temperature = (bytes[1] << 8) + bytes[0];
> 
> ```

Beware that this does not [support negative values](https://www.thethingsnetwork.org/forum/t/decrypting-messages-for-dummies/4894/4).

---

<div class="post-metadata">

**Author:** ![obaeyens](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/obaeyens/32/25844_2.png) [@obaeyens](https://www.thethingsnetwork.org/forum/u/obaeyens)\
**Post date:** [January 10, 2020, 12:38pm UTC](https://www.thethingsnetwork.org/forum/t/heltec-cube-cell-decoder-for-bme680/33252/7 "2020-01-10T12:38:05Z")

</div>

That is an extremely valid point! Negative values
