- Go to TTN europe
- Create an application
- Register a end device, enter end device manually, Lora, then in JoinEUI put random numbers. Generate, generate
- Download this repository
- Change the platformio ini file with the frequencies of europe, and fill te file of
main/credentials.h
with the keys of the device. TAKE NOTE THAT YOU NEED TO WRITE SOME VARIABLES IN LSB AND OTHERS IN MSB.
In the example we are going to send the data to a mapper, that is a easy way to know that the system is working:
- Go to Integration>Webhooks> TTNMapper.
- Fill it with your data
- Go to payload formatters and uplink, put the next code with Custom Javascript formatter:
function Decoder(bytes, port) {
var decoded = {};
decoded.latitude = ((bytes[0]<<16)>>>0) + ((bytes[1]<<8)>>>0) + bytes[2];
decoded.latitude = (decoded.latitude / 16777215.0 * 180) - 90;
decoded.longitude = ((bytes[3]<<16)>>>0) + ((bytes[4]<<8)>>>0) + bytes[5];
decoded.longitude = (decoded.longitude / 16777215.0 * 360) - 180;
var altValue = ((bytes[6]<<8)>>>0) + bytes[7];
var sign = bytes[6] & (1 << 7);
if(sign) decoded.altitude = 0xFFFF0000 | altValue;
else decoded.altitude = altValue;
decoded.hdop = bytes[8] / 10.0;
decoded.sats = bytes[9];
return decoded;
}
Then upload the code and everything should be on place to upload the data to the network.