Hello all, I am just now using the ttn-otaa example from the TTN_esp32 library, it connects and sends data well to The Things Network. However, When I send downlink bytes from TTN, I keep getting random numbers. I send down bytes in ASCII format. I sent '31', '32', and '33'. I was expecting to get 49 from 31, 50, from 32, and 51 from 33. Instead, I got 17 from 31, and 49 for both 32 and 33. This is the unaltered template for the ttn-otaa sketch, does anyone how to change this? number I'm looking to change is the variable "payload[]".
#include <TTN_esp32.h>
#include "TTN_CayenneLPP.h"
/***************************************************************************
* Go to your TTN console register a device then the copy fields
* and replace the CHANGE_ME strings below
****************************************************************************/
const char* devEui = "FILLMEIN"; // TTN Device EUI but removed for this post
const char* appEui = "FILLMEIN"; // TTN Application EUI but removed for this post
const char* appKey = "FILLMEIN"; // TTN Application Key but removed for this post
TTN_esp32 ttn ;
TTN_CayenneLPP lpp;
void message(const uint8_t* payload, size_t size, int rssi)
{
Serial.println("-- MESSAGE");
Serial.print("Received " + String(size) + " bytes RSSI=" + String(rssi) + "db");
for (int i = 0; i < size; i++)
{
Serial.print(" " + String(payload[i]));
// Serial.write(payload[i]);
}
Serial.println();
}
void setup()
{
Serial.begin(115200);
Serial.println("Starting");
ttn.begin();
ttn.onMessage(message); // Declare callback function for handling downlink
// messages from server
ttn.join(devEui, appEui, appKey);
Serial.print("Joining TTN ");
while (!ttn.isJoined())
{
Serial.print(".");
delay(500);
}
Serial.println("\njoined !");
ttn.showStatus();
}
void loop()
{
static float nb = 18.2;
nb += 0.1;
lpp.reset();
lpp.addTemperature(1, nb);
if (ttn.sendBytes(lpp.getBuffer(), lpp.getSize()))
{
Serial.printf("Temp: %f TTN_CayenneLPP: %d %x %02X%02X\n", nb, lpp.getBuffer()[0], lpp.getBuffer()[1],
lpp.getBuffer()[2], lpp.getBuffer()[3]);
}
delay(10000);
}