Skip to main content
All CollectionsUser Guides
Change default device location
Change default device location

How to change a device's default location

Sergio M avatar
Written by Sergio M
Updated over 3 months ago

Ubidots lets you assigns the location of a device in four 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 device's latitude (lat) and longitude (lng) coordinates directly into the device.

  3. Sending a variable called "gps", "location" or "position" with latitude and longitude in the context

  4. Select the location based on a variable: If you don't have a variable called “gps”, “location” or “position”, you can choose any other variable inside the device that contains “lat” and “lng” values in its context.

1. Change default device locations

All new devices have an unknown location until specified.

To set a location, simply move the pin to the desired location:

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 drop-down from "Auto" to "Manual".

With a manual Location, you need only enter the GPS Coordinates of your desired location and Ubidots's 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.

4. Select the location based on a variable

To place a device location within a variable, you can select one as shown below, make sure the variable selected carry "lat" and "lng" values in its context:

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 lng.

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?