Setup LGT-92 as a tracker at Ubidots

Hi There. It might be a noob question but i am a little stuck.

I have a LGT-92 and it is connected to TTN. I have uploaded the default Payload with comes in the manual and everything seems to be working. After a few test with TTN Mapper i printed a box where it should do its work being a tracker.

I did subscribe to Ubidots to do the tracking and here lies a probably small engagement. Ubidots displays all the data that comes from the device. But it doesn’t display the coordinates in the right format to get a hold on the position. After a small talk to support they said that i need to add the following line:

{“position”: {“value”: 0, “context”: {“lat”: YOUR_LAT_VAL, “lng”: YOUR_LNG_VAL}}}

As i am not a real programmer i did add this line to the payload and that doesn’t work.

Could some tell me what to do to get it right and explain it a little bit?

IMG_2747

And this is the part i currently have in the Payload:

//The function is :
function Decoder(bytes, port) {
// Decode an uplink message from a buffer
// (array) of bytes to an object of fields.
var value=bytes[0]<<16 | bytes[1]<<8 | bytes[2];
if(bytes[0] & 0x80)
{
value |=0xFFFFFF000000;
}
var latitude=value/10000;//gps latitude,units: °

value=bytes[3]<<16 | bytes[4]<<8 | bytes[5];
if(bytes[3] & 0x80)

{
value |=0xFFFFFF000000;
}
var longitude=value/10000;//gps longitude,units: °

var alarm=(bytes[6] & 0x40)?“TRUE”:“FALSE”;//Alarm status

value=((bytes[6] & 0x3f) <<8) | bytes[7];
var batV=value/1000;//B

value=bytes[8]<<8 | bytes[9];
if(bytes[8] & 0x80)
{
value |=0xFFFF0000;
}
var roll=value/100;//roll,units: °

value=bytes[10]<<8 | bytes[11];
if(bytes[10] & 0x80)

{
value |=0xFFFF0000;
}

var pitch=value/100; //pitch,units: °

return {
Latitude: latitude,
Longitud: longitude,
Roll: roll,
Pitch:pitch,
BatV:batV,
ALARM_status:alarm,
};
}

if this is your code, there is at least an error here (missing “e”); (although this may be not the reason, if they ask for some specific format).

I corrected the minor error of typo but that doesn’t solve it either. Ubidots support gives me links on how to setup a device at TTN and Ubidots but that part is already working. Nobody else here have a clue?

Hi everyone, Maria from Ubidots here. I just bumped into this forum while reading about the LGT-92 so I thought I’d jump in. I have an LGT-92 setup in my Ubidots account and is working just fine:

dragino

Please find my decoder below. I took the one in Dragino’s user manual and only changes one line of code so the returned JSON is one that Ubidots can understand as a position (needs to be a tuple, or within a “context”, as @KruisR’s attempt). In this case, I’m using a tuple:

JSON payload returned by the decoder:

{
“position”: {“lat”: 6.32122, “lng”: -75.23234},
“alarm”: false,
“batV”: 2.761,
“pitch”: 4.57,
“roll”: 0.83
}

Here my decoder:

function Decoder(bytes, port) {
  // Decode an uplink message from a buffer
  // (array) of bytes to an object of fields.
  var alarm=(bytes[6] & 0x40)?true:false;//Alarm status
  value=((bytes[6] & 0x3f) <<8) | bytes[7];
  var batV=value/1000;//Battery,units:Volts
  value=bytes[8]<<8 | bytes[9];
  if(bytes[8] & 0x80)
  {
    value |=0xFFFF0000;
  }
  var roll=value/100;//roll,units: °
  value=bytes[10]<<8 | bytes[11];
  if(bytes[10] & 0x80)
  {
    value |=0xFFFF0000;
  }
  var pitch=value/100; //pitch,units: °
  var json={
    roll:roll,
    pitch:pitch,
    batV:batV,
    alarm:alarm
  };
  var value=bytes[0]<<16 | bytes[1]<<8 | bytes[2];
  if(bytes[0] & 0x80)
  {
    value |=0xFFFFFF000000;
  }
  var value2=bytes[3]<<16 | bytes[4]<<8 | bytes[5];
  if(bytes[3] & 0x80)
  {
    value2 |=0xFFFFFF000000;
  }
  if (value == 0x0FFFFF && value2 == 0x0FFFFF)
  {
  //gps disabled (low battery)
  } else if (value === 0 && value2 === 0) {
  //gps no position yet
  } else {
    json.position = {"lat": value/10000, "lng": value2/10000};
  }
  return json;
}

Apparently, the "context" is required nowadays.