ElectronicCats / CayenneLPP

Library for Arduino compatible with Cayenne Low Power Payload
http://electroniccats.com/
MIT License
106 stars 48 forks source link

Cayenne decode some payploads #39

Closed menyDev closed 1 year ago

menyDev commented 1 year ago

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

include

CayenneLPP lpp(51);

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

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

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.print("HEX: "); Serial.print(payloadString); Serial.print(" | SIZE: "); Serial.println(payloadString.length());

delay(5000); }`

Code 2: `#include

include

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.print("HEX: "); Serial.print(payloadString); Serial.print(" | SIZE: "); Serial.println(payloadString.length());

delay(5000); }`

The output for code 1 is HEX: 076701090868ad and for code 2 HEX: 01740140

I also test with .addGenericSensor()and .addSwitch(), and the ttn output decoded is the same

xoseperez commented 1 year ago

Hi @jazhe Voltage is not supported on TTN. This library extends the original CayenneLPP with new data types. If you want to decode all of them on TTN you have to use the payload formatter you can find under the decoders folder (the minified version).

jazhe commented 1 year ago

Hi @jazhe Voltage is not supported on TTN. This library extends the original CayenneLPP with new data types. If you want to decode all of them on TTN you have to use the payload formatter you can find under the decoders folder (the minified version).

@menyDev

menyDev commented 1 year ago

Thanks for the support! Now all works