Integration TTN with Ubidots

Hi,
I integrated Ubidots with TTN, it works great!

Now I would like to create a map on Ubidots but Ubidots doesn’t accept latitude and longitude as independent variables. Position must be integrated in Json format as follow.

{“position”: {“value”:1, “context”:{“lat”: “-23.1264”, “lng”: “52.2314”}}}

Is it possible to create a json in the decoder like this?
decoded.lat = ((bytes[12]<<16)>>>0) + ((bytes[13]<<8)>>>0) + bytes[14];
decoded.lat = (decoded.lat / 16777215.0 * 180) - 90;
decoded.lon = ((bytes[15]<<16)>>>0) + ((bytes[16]<<8)>>>0) + bytes[17];
decoded.lon = (decoded.lon / 16777215.0 * 360) - 180;

and something like…
decoded.position= {“value”:1, “context”:{“lat”: decoded.lat, “lng”:decoded.lon}}}

Thanks

Solved, in TTN payload decoder
decoded.tempUbi={“value”:decoded.Temp, “context”:{“lat”: decoded.lat,“lng”: decoded.lon}};

1 Like