How to display data from your things on a map with thethings.iO IoT platform

Some customers just contact at thethings.iO because they heard that it’s super simple to use thethings.iO IoT platform to visualize their devices, draw some points in a map or apply business logics on their connected devices. And that’s right! thethings.iO is the most simple IoT platform. Nowadays we are helping hundreds of companies and developers to reduce the time to market of their IoT projects just using thethings.iO IoT solution.

One of the most popular question is how to display data from connected devices on a map. Seriously it’s very simple to do it with thethings.iO IoT platform. Nevertheless, there are tricks to have more fancy maps, it all depends if you have 2, 3 or five minutes 🙂

How to send geolocated data to the IoT platform

First of all, it’s important to understand that thethings.iO has 2 ways to geolocation things.

Locate the device

We call this $geo resource, or also magic resource. This magic resource allows the update of the current thing position in GeoJSON format. GeoJSON and legacy [long, lat] pairs are accepted as valid input value, or you can use the geo attribute: the final value will be saved in GeoJSON format.

Find here the code to send data to locate the device.


{
"values":
[{
"key": "$geo",
"value" : {
"type": "Point",
"coordinates": [2.154007, 41.390205]
}
},
// OR using legacy [long, lat]
{
"key": "$geo",
"value" : [2.154007, 41.390205]
},
// OR using geo attribute object
{
"key": "$geo",
"value" : null,
"geo" : {
"lat": 41.390205,
"long": 2.154007
}
}]
}

Locate a sensor read in the space and time

Sometimes the GPS reading does not correspond to a sensor read position, so this is the reason why we differentiate among them. Find here the code to send data with this second way to geolocate a device or a sensor read.


{
"values":
[{
"key": "my-geolocated-key",
"value" : 23,
"geo" : {
"lat" : 41.4121132,
"long" : 2.2199454
}
}]
}

How to show things on a map

Now that we have geolocated devices, let’s paint the devices and routes on a map.

It’s simple right? Feel free to register at thethings.iO and contact us if you have any question.

  • Jen

    Hi, I am currently using an arduino uno and sparkfun venus GPS. I have manage to send the values to thethings.io, however it is displayed as only values and not latitude and longitude. How could I convert the numbers to geolocations to create the map widget on the dashboard. I have also tried the code above, but I am not sure where the code should go.