Hello Tago Support Team, I am working on a project which needs an object GPS location. The used GPS module provides output in NMEA standard format and later converted this with an exact Lat/Long GPS positioning coordinates for the connected device. Please assist further how to add and setup parsing this Lat/Long GPS positioning coordinates’ data within the TagoIO platform for added device to be display an exact location of the object on the TagoIO dashboard visual map? Thanking you.
Hi,
1. First thing you need to do is to have your device connected to TagoIO and sending data. The data doesn’t need to be accepted from the API, but it must show up in the Live Inspector in your device’s page, so you can go to the next step.
2. This step really depends on how much freedom you have with how the sensor is communicating with TagoIO. You can set the correct format in your sensor, in the LNS or directly from TagoIO.
TagoIO only accepts and store data that is in a JSON format, containing at least the variable key. For location registers, you need to also include the location key.
{
"variable": "location",
"value": "sensor location",
"location": { "lat": 3404.7041778, "lng": 07044.3966270 }
}
2.1 - Parsing in the sensor/gateway/LNS: Just make sure you’re sending the data as a JSON specified above.
2.2 - Parsing at TagoIO: You will be required to write a JS code in the Payload Parser of your device. The result of the payload parameter in the payload parser is what will be stored, and it must be formatted as the JSON mentioned on step 2.
Since parsing at TagoIO really depends on how the data is arriving, I would need the logs of your Live Inspector to provide better support.
Hello Vitor, Thank you very much for your prompt assistance on my TagoIO application issue. I really appreciated it.
As a bit new with TagoIO could you please assist me further how to make the device connected to TagoIO and sending data, which must shown up in the Live Inspect in my added device page? Thanks.
You can check the documentation on how to send data, and we also have webinars/video tutorials:
Okay! thanks for providing the documentations and allow me sometime to review with these details and get back to you soon.
Hello Vitor, after a long workout on GPS module to make it work with TagoIO platform I finally succeeded to manage to get Live Inspector log, please refer to the attachment to be reviewed by you. Next, please assist further step by step platform configuration procedure how to show this live GPS location on dashboard? Thanking you.
Great work!
Now that you have the data being send to TagoIO, the next step would be to parse this information to a data register that the widgets can read.
In order to do that, you need to write a Payload Parser code. You can see the option in your device’s page. Enable it.
By following the following guide In-depth guide to payload parser, you probably should be able to parser it by yourself. But here is a quick code to help you:
/* This is a generic payload parser that can be used as a starting point MQTT devices
** The code expects to receive comma separated data, and not JSON formatted data.
**
** Testing:
** Testing:
** You can do manual tests to the parse by using the Device Emulator. Copy and Paste the following JSON:
** [{ "variable": "payload", "value": "lat/lng=90;90", "metadata": { "mqtt_topic": "data" } } ]
*/
// Prevents the code from running for other types data insertions.
// We search for a variable name payload or a variable with metadata.mqtt_topic
const mqtt_payload = payload.find((data) => data.variable === "payload" || (data.metadata && data.metadata.mqtt_topic));
if (mqtt_payload) {
// Split the content by the separator "="
// splitted_value content will be ['lat/lng', '90;90']
// index starts from 0
const splitted_value = mqtt_payload.value.split('=');
// Now we split the lat and lng by the separator ";"
// The result will be [90,90], which we use deconstruction to automatically set it to lat and lng variable.
const [lat, lng] = splitted_value[1].split(';');
// Normalize the data to TagoIO format.
// We use Number function to cast number values, so we can use it on chart widgets, etc.
const data = [
{ variable: 'location', value: splitted_value[1], location: { lat: Number(lat), lng: Number(lng) }},
];
// This will concat the content sent by your device with the content generated in this payload parser.
// It also adds the field "serie" to be able to group in tables and other widgets.
const serie = String(Date.now());
payload = payload.concat(data).map(x => ({ ...x, serie }));
}
Make sure you turn on the Live Inspector while testing the payload parser, that way you can check if the parser is throwing any error. I also recommend to use the emulator as it can make much easier to test quick changes.
The goal of this parser is to output the location variable to your device’s bucket. Once the data is being accepted, you can just create a Map Widget in the dashboard and enter the location variable as the data for your device.
Hello Vitor, Thanks for keep supporting. I really appreciated.
Got the real time GPS location from the connected GPS module on map widget. But I am also getting your headquarters’ default location every time when open the map widget. Please refer to the attached screenshot. How to remove and fix this problem? Thank you.
IT can be that you have this information stored in your device, and you need to remove it.
You can also check in the Live Inspector if you’re not sending the headquarters location for some reason.
Hello Vitor, Got it and fixed the issue. Thanks.
Secondly, please let me assist further how to remove the Lat/Long coordinates for the location name and add name of end node device just like same as shown “TagoIO Headquarters” for the location? Thanking you.
You need to change the value in the payload parser.
As it is, it is just copying your lat and lng to show as it was send by the device. The widget just use the location key to resolve the location, the value is what shows up in the infobox.
Notice that TagoIO will not resolve the latitude and longitude to an address for you. So you can send the name from your device or have a fixed name in the payload parser. Another way is to use a 3rd-party API to resolve the addres using an Analysis.
Hello Vitor,
Okay! Got it. Thank you for your valuable support and hope for the same in near future if any.