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

  1. Change the default device location: click on the map within the device to set the specified location.
  2. Manually assigning a location: enter your devices Lat and Long coordinates directly into the device.
  3. Sending a variable called Position with latitude and longitude in the context

1. 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":

2. Manually Assigning a location

Within all devices, you may assign the position of your asset manually. In the bottom left-hand corner of your device data display, toggle the dropdown from "Auto" to "Manual".

With a manual Location, you need only enter the GPS Coordinates of your desired location and Ubidots' maps will update automatically. 

Pro-tip: to easily locate your desired coordinates, use Google Maps to locate your position and pull the coordinates from the google URL. For example, here are the coordinates to UC Berkeley's Doe Library.

3. Sending a Variable called "Position"

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. Ubidots Forums also provide a helpful host of resources to sending an assets Lat and Long.

With your variables reporting to Ubidots, you need only select the variable attached to the devices position and activate a widget. 

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?