This is a simple sketch demonstrating the capability of the TTGO T-Beam as a TTN Mapper Node on The Things Network LoraWAN.
Forked from MichaelEFlip/Lora-TTNMapper-T-Beam from sbiermann/Lora-TTNMapper-ESP32 and with some information/inspiration from cyberman54/ESP32-Paxcounter and Edzelf/LoRa. The forked repo from hottimuc was converted to a PlatformIO project (currently for hardware revision >= 0.8).
LMIC-Arduino : Make sure to get the last version - 1.5.1 (PlatformIO will take care of this)
Copy all from here locally, open it with PlatformIO, rename config.h.template to config.h and fill with your ABP credentials. Then upload it to the T-Beam.
On The Things Network side, the settings needed are available here.
Configuration in The Things Network Console:
Payload uplink formatter type: custom Javascript formatter
function decodeUplink(input) {
var bytes = input.bytes;
var decoded = {};
var latitude = ((bytes[0]<<16)>>>0) + ((bytes[1]<<8)>>>0) + bytes[2];
latitude = (latitude / 16777215.0 * 180) - 90;
var longitude = ((bytes[3]<<16)>>>0) + ((bytes[4]<<8)>>>0) + bytes[5];
longitude = (longitude / 16777215.0 * 360) - 180;
var altValue = ((bytes[6]<<8)>>>0) + bytes[7];
var sign = bytes[6] & (1 << 7);
var altitude;
if(sign)
{
altitude = 0xFFFF0000 | altValue;
}
else
{
altitude = altValue;
}
var hdop = bytes[8] / 10.0;
return {
data: {
latitude:latitude,
longitude:longitude,
altitude:altitude,
hdop:hdop
},
warnings: [],
errors: []
};
}