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);
}