Hello all, I’m using the TTN_esp32 library and I’m struggling with the downlink portion. I’m sending downlink to my heltec Wi-Fi LoRa32 V2 but I’m only getting random numbers. I’m using the ttn-otaa example sketch. Has anyone ever used this library before? I’m wondering if this is the result of a pin mapping issue. Do I need to declare which board I’m using? It says that the pre-integrated boards work automatically but it also refrences the Arduino-LMIC library for pin mapping found here mcci-catena/arduino-lmic: LoraWAN-MAC-in-C library, adapted to run under the Arduino environment (github.com)
This is the link to the library I’m using, rgot-org/TheThingsNetwork_esp32 (github.com)
and below is the example ttn-otaa sketch I’m using as well.
#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 = "CHANGE_ME"; // Change to TTN Device EUI
const char* appEui = "CHANGE_ME"; // Change to TTN Application EUI
const char* appKey = "CHANGE_ME"; // Chaneg to TTN Application Key
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);
}