07 July 2020

Simulating a LoRA node GPS position on TTN

A simple way to see your LoRAWAN node or gateway coverage is to use the TTN Mapper service.

In order to get my node visible on TTN Mapper I had to enable the Mapper Integration within my Application and output notes's position. TTN Mapper documentation says that either the node sends its position in the payload or you can "pair" it with a smartphone app and keep both close to each other (ie the same vehicle, the same bag, ...).

OTOH if the node sends its position it must be decoded into a JSON through some code written in the web console, Decoder section under Payload Formats. So, why not write a static Decoder function that returns the required variables?

You need to produce latitude and longitude. Optionally altitude and hdop. If a node isn't moving, that's quite easy! Recover the coordinates in your preferred way (smartphone GPS app, GPS tracker, a web mapping service, ...) and fill in your code like this:

function Decoder(bytes, port) {

  var decoded = {};


  // your node's actual coordinates
  decoded.latitude = X;  // a value like 10.456 (this is North-South or equator)
  decoded.longitude = Y; // a value like 80.123 (this is East-West of Greenwich)
  // your node's height above ground (or is it m.a.s.l.?)
  decoded.altitude = Z;
  // your position accuracy, 5 is fine
  decoded.hdop = 5;

  return decoded;
}

Once the Decoder function is saved, all further transmissions within your TTN Application will carry those variables (added cloud-side once the data is received through a gateway).

Can you see a cheating danger in here? I do. But fortunately there isn't a LoRA distance competition, yet.

Let's get my signal as far away as possible, as strong as possible!