Cayenne integration: Where is my payload?

(Adam Jp) #21

Wow awesome work, thanks!

(Eptak) #22

Great work TTN ! Thanks for pushing Cayenne LPP !
Per the JS decoder function, we are going to open source ou Cayenne LPP decoder.
We'll be able to provide you the code then :slight_smile:

(Edzo A. Botjes) #24

Hi All, great discussion and great reads on Cayenne LPP.
Thank you so much..

I tried to combine the TTN Build your own Sensor Workshop, with an implementation of Cayenne LPP.
I think the payload looks ok, but Cayenne does not accept it, since on the dashboard I only see the RSSI and SNR.

Is there an cayenne LPP Decoder online available that I can feed my byte string and then see what I did wrong? :slight_smile:

// Cayenne LPP Byte definition

// Cayenne LPP Payload buildup

// Lora TTN via LMIC and bmp280 code

// Edzo's First LoRa TTN Cayenne LPP Implementation

// Byte string in the Lora TTN Payload
// 036700E9046800057328163C94100F141E3D6F08

(Arjan) #25

It's not too hard to manually decode this? I run into problems using the documentation:

03 67 00E9            67 = temperature
04 68 00              68 = humidity
05 73 2816            73 = barometer
3C 94 100F141E3D6F08  94 = unknown type?

(My guess is that you're missing xx 88 at the start of the last section, for GPS location. Any online decoder would fail as well, so is of little help...)

(Edzo A. Botjes) #26

@arjanvanb Thanks for the hint.

I first build a hardcoded message with the existing code
and then used the example functions to build up payload with the sensor data
and now it works! :slight_smile:

I needed some reading on Hex Decimals and and Byte Array.. and learned a lot.
Thanks for the nudge into the right direction :slight_smile:

Code on github is updated.



I have a TTN/Cayenne device integration. This device has a DHT11 sensor and the payload is in LPP format.
The application data in the TTN Console looks fine to me: 036700C804684400
channel 03, type 67, tempvalue: 20C and channel 04, type 68, humvalue: 34%

My problem; I only see the RSI and SNR widget in Cayenne and reading the answers in previous posts there must be something wrong with my payload but I have no idea. Anyone else?

(Arjan) #28

That should be one byte, not two, for the value. But you're sending 04 68 4400.


Thanks Arjan, that is exactly what played in my mind.
At the moment I've no access to the code but I'll try to remove the last byte.


int16_t val;
uint8_t channel;
byte buffer[8];
uint8_t cursor = 0;

val = temperature;
val = temperature * 10;
channel = 0x03;
buffer[cursor++] = 0x03;
buffer[cursor++] = LPP_TEMPERATURE;
buffer[cursor++] = val >> 8;
buffer[cursor++] = val;

val = humidity;
channel = 0x04;
buffer[cursor++] = channel;
buffer[cursor++] = LPP_RELATIVE_HUMIDITY;
buffer[cursor++] = humidity * 2;

// Check if there is not a current TX/RX job running
if (LMIC.opmode & OP_TXRXPEND) {
Serial.println(F("OP_TXRXPEND, not sending"));
} else {
// Prepare upstream data transmission at the next possible time.
//LMIC_setTxData2(1, buffer, sizeof(buffer)/sizeof(buffer[0]), 0);
LMIC_setTxData2(1, buffer, 7, 0); //brute force

(Arjan) #31


byte buffer[7];
LMIC_setTxData2(1, buffer, sizeof(buffer)/sizeof(buffer[0]), 0);

...or better yet:

byte buffer[20]; // any maximum size your payload might need
buffer[cursor++] = ...
buffer[cursor++] = ...
LMIC_setTxData2(1, buffer, cursor, 0);

(Ivo Noorhoff) #32

I'd really like to know this as well. Cayenne seems like a great tool and i want to use it but use more efficient payloads. The channel is inferred from the node ID, node sensor has a fixed structure so there is no need to repeat the meta data for the sensor data every time etc.

(Rustie0125) #33

Hi Johan

Im trying to use your example code on a 32u4 Lora feather with thing works. few questions if you dont mind.

* Are you not missing the DEV EUI input?
* is the input(s) straight copy and past from TTN like so or does it need to be reveresed the same as the LMIC stuff?
* const char *appEui = "70B3D57EF0004C11";
* const char *appKey = "0000110220330440550660770880990A";

I have installed your library, copied your example changed the two keys and uploaded the code but i see not registration attemps in TTN or any data flowing.

Thank you


The example in TheThingsNetwork Arduino library are specifically for Arduinos with the Microchip RN2xx3 module. With the 32u4 LoRa feather I'd suggest using LMiC. And then, indeed, you need to reverse the byte order.

Easy way to plot sensor data to online graph
(Douwey) #36

I’m also having trouble getting my data to Cayenne. Can you guys help me with what I’m doing wrong? (I know it’s not the prettiest code)

    void do_send(osjob_t* j) {
  // Check if there is not a current TX/RX job running
  if (LMIC.opmode & OP_TXRXPEND) {
    // Serial.println(F("OP_TXRXPEND, not sending"));
  } else {
    // Read distance
    int distance = readDistance();
    mydata[0] = (uint8_t)distance;

  //  LMIC_setTxData2(1, mydata, sizeof(mydata), 0);

    // Cayenne LPP Protocal Definition
#define LPP_DIGITAL_OUTPUT         1     
    // Init declaration
    uint8_t val;
    uint8_t channel;
    byte buffer[8];
    uint8_t cursor = 0;

    // set Sensor Barometric Pressure into payload
    val = mydata;
    channel = 0x04;
    buffer[cursor++] = channel; 
    buffer[cursor++] = LPP_DIGITAL_OUTPUT; 
    buffer[cursor++] = val; 

    return cursor;
    // Check if there is not a current TX/RX job running
    if (LMIC.opmode & OP_TXRXPEND) {
      Serial.println(F("OP_TXRXPEND, not sending"));
    } else {
      // Prepare upstream data transmission at the next possible time.
      LMIC_setTxData2(1, buffer, sizeof(buffer) / sizeof(buffer[0]), 0);

      //Serial output of message
      Serial.println(F("Sending: "));
      for (byte b = 0; b < (sizeof(buffer) / sizeof(buffer[0])); b++) {

      // Serial.println(F("Packet queued"));
    // Next TX is scheduled after TX_COMPLETE event.



you have an Cayenne account and set integrations in the Console to Cayenne ? (just to be sure)


Code is not very easy to read. Maybe use the lpp library in the sketch? TTN LPP GitHub . Check if message is received on gateway and application. If so try a manual upload of the data from console and see if it is received by mydevices.

(Arjan) #39

…but it seems to me you’re not filling the whole buffer with data.

So, maybe something like:

LMIC_setTxData2(1, buffer, cursor, 0);
for (byte b = 0; b < cursor; b++) {

Also, if I understand your code formatting correctly then it seems the return cursor; exits the function prematurely (and Serial.println(F("Sending: ")); is never even invoked), but I’ll leave proper formatting to you, before asking again…

Admitting that is never an excuse!