Ubidots lets you assigns the location of a device in two ways:

  • Clicking on the map on your Dashboard to set the specified location
  • Sending a variable called position with latitude and longitude in the context

Change default device locations

All new devices have an unknown location until specified. To set a static simply search the map and click to pinpoint your device:

Once you select the specified location you have to confirm it selecting "Yes":

Sending the position in a variable

To place a device location within your code, you need to send a variable called "position" with the devices latitude and longitude specified in the context. The data structure of the message should look like this:

{"position": {"value":1, "context":{"lat":25.7742700, "lng": -80.1936600}}}

As you can see above we set the coordinates into the structure; depending on the device and the code that you are working with, you can specify the coordinates obtained from your device into the structure for regular device location updates.

"context":{"lat": latitud_obtained, "lng": longitud_obtained}

With code similar to this, you will be sending the current device position as a "position" variable into your Ubidots account; keeping tabs on your device as it moves around the country or globe.

Please reference to the Ubidots API Documentation for how to build the request message to POST data to Ubidots. 

As you can see below, different HTTP requests have been sent to Ubidots containing different coordinates. The resulting dashboard now identifies and adjusted automatically based on a device's location:

If you look to test how this context POST works on your Ubidots account, reference this post for our teams 3 favorite HTTP request simulators and build your request!

Did this answer your question?