Cayenne decode some payploads

Hi, I am confused with this, I run the code 1 on my Wireless Stick Lite from Heltec and when I decode with CayenneLPP on ttn everything works fine, but then I do just one modification (code 2) and set other value to send and try to decode the payload the output is invalid on ttn.

What’s wrong with my code? I’m a beginner with Cayenne and ttn but I would think that the codes are almost the same

Code 1:

#include <Arduino.h>
#include <CayenneLPP.h>

CayenneLPP lpp(51);
DynamicJsonDocument jsonBuffer(1024);
JsonObject root = jsonBuffer.to<JsonObject>();

void setup() {
  Serial.begin(115200);
}

void loop() {
  lpp.reset();
  lpp.addTemperature(7, 26.5f);
  lpp.addRelativeHumidity(8, 86.6f);

  lpp.decodeTTN(lpp.getBuffer(), lpp.getSize(), root);

  uint8_t *payload = lpp.getBuffer();

  char buffer[7];
  String payloadString;

  for (int i = 0; i < lpp.getSize(); i++) {
    sprintf(buffer, "%02x", payload[i]);
    payloadString += buffer;
  }

  Serial.println();
  Serial.println("################### LOOP ###################");

  Serial.print("HEX: ");
  Serial.print(payloadString);
  Serial.print(" | SIZE: ");
  Serial.println(payloadString.length());

  delay(5000);
}

Code 2:

#include <Arduino.h>
#include <CayenneLPP.h>

CayenneLPP lpp(51);

void setup() {
  Serial.begin(115200);
}

void loop() {
  lpp.reset();
  lpp.addVoltage(1,3.2f);

  uint8_t *payload = lpp.getBuffer();

  char buffer[7];
  String payloadString;

  for (int i = 0; i < lpp.getSize(); i++) {
    sprintf(buffer, "%02x", payload[i]);
    payloadString += buffer;
  }

  Serial.println();
  Serial.println("################### LOOP ###################");

  Serial.print("HEX: ");
  Serial.print(payloadString);
  Serial.print(" | SIZE: ");
  Serial.println(payloadString.length());

  delay(5000);
}

Showing us the output would help! But I suspect it will be something to do with the code you haven’t included where you are passing over the hex to be transmitted. Apart from anything else, String isn’t an appropriate function to use for firmware but I’d be surprised that the send function needs a hex string - that’s usually only for AT command based devices and this isn’t one of them AFAIK

Sure, the payloadString for code 1 is Hex: 076701090868ad

and for code 2 Hex: 0x01740140

The string payload is only for check the format and output on Payload formaters of my end device on ttn

I think you may have found an issue with the TTI LPP decoder as 01740140 decodes OK in my head but as you say, not on the console. You will need to file an issue on GitHub.

If you are using Cayenne, then it will pass it over as is. If you aren’t using Cayenne, then don’t use LPP, it’s rather verbose.

1 Like

OK, I’ill do it. Thanks for your support