Visualize LR1110 Geolocation Data on Ubidots

Visualize LR1110 Geolocation Data on Ubidots

LR1110

This guide shows you an example of using The Things Stack integrations to interact with LoRa Cloud™ Device & Application Services to acquire the position solution for the LR1110-based tracking device, and to send that position data to a map widget on Ubidots.

LR1110 is a long range, ultra-low power transceiver designed by Semtech, offering Wi-Fi and GNSS geolocation capabilities. The LoRa Basics™ Modem-E is a software embedded inside LR1110 that supports the LoRaWAN protocol stack, as well as the application layer functions and APIs.

The Device & Application Services with Geolocation for Modem-based Devices API on LoRa Cloud™ allows interacting with Device & Application Services to make efficient use of the LR1110’s geolocation features.

Prerequisites

  1. A user account on LoRa Cloud™.

  2. A Ubidots user account with an upgraded plan.

Warning:
The UbiFunctions module used in this guide is currently not available for the STEM plan.
Note:
This guide assumes you have already added your LR1110-based tracking device to The Things Stack. See Adding Devices section for a detailed info.

Prepare a LoRa Cloud™ Setup

To prepare the setup for your device’s location resolution, first go to LoRa Cloud™ and select LoRa Cloud Device & Application Services after logging in to your account.

LoRa Cloud Device & Application Services

On the left hand menu, navigate to the Device Owners tab and click the Create new owner button. Enter a Name, choose a Plan and select Submit.

Creating a device owner

Next, navigate to the Manage Devices tab on the left hand menu and click the Add devices button. Enter your device’s EUI and click the Add devices button.

Adding a device

If you look under the Manage Tokens tab, you can find or create a new token needed for the next step.

Manage tokens

Create a LoRa Cloud™ Integration

The next step is to integrate The Things Stack with LoRa Cloud™.

In The Things Stack Console, navigate to the Integrations menu and select LoRa Cloud.

Paste the token from LoRa Cloud™ in the Token field and enable the LR1110 demo encoding by checking the box.

LoRa Cloud integration

At this point, your device will send the location updates to the LoRa Cloud™ Device & Application Services. After receiving your device’s location solution from Device & Application Services, in your device’s Live data tab in The Things Stack, you will find a message of the Forward location solved message type. This message contains the object of the following structure:

"location_solved": {
      "service": "lora-cloud-device-management-v1-wifi",
      "location": {
        "latitude": 51.455,
        "longitude": 5.458,
        "accuracy": 15,
        "source": "SOURCE_WIFI_RSSI_GEOLOCATION"
      }
    }
Note:
Keep on mind that these values can change depending on the type of scans your device is performing - WiFi or GNSS.

Prepare the Setup on Ubidots

Next, we want to send the location solution data to Ubidots and show it on a map widget. Before integrating, you need to prepare the setup on Ubidots first.

This setup is only slightly modified comparing to the one in the Ubidots integration guide, so feel free to follow those steps. The only change you need to make is replacing this UbiFunction method:

def parse_tti_data(data):
    return data['uplink_message']['decoded_payload']

with the following one:

def parse_tti_data(data):
    return data['location_solved']

When you click the Make it live button, copy the HTTPs Endpoint URL assigned to your UbiFunction, and you are ready to go back to The Things Stack to create a Webhook integration.

Create a Webhook Integration with Ubidots

In The Things Stack Console, select Webhooks under Integrations on the left hand menu and choose the Custom webhook.

Note:
The Ubidots Webhook template is also available, but it is predefined to send only the Uplink message type via Webhook integration. You could modify the Webhook integration after creating it with this template, but we recommend using a custom webhook and following the next steps to avoid the possible confusion.

The steps to be taken follow the Creating Webhooks guide and are described below in detail.

  • Create a Webhook ID.
  • Add a Content-type header entry with application/json as a value.
  • Select JSON as a Webhook format.
  • In the Base URL field, paste the UbiFunction URL you copied in the previous step.
  • Enable the Location solved message type.
Ubidots Webhook integration

Visualize Data on a Ubidots Map Widget

Go back to Ubidots and find your device by navigating to the Devices tab. After some new data reaches Ubidots, you will see the location variable automatically appearing on your device’s dashboard.

On the left, there is a window containing important info about your device. Under Location section, set the Mode to Auto. This tells Ubidots to use the location object to automatically determine your device’s location. The Latitude and Longitude parameters will acquire the values from the latitude and longitude variables of the location object shown on the dashboard.

Ubidots device data

Now navigate to the Data tab and select Dashboards. Create a new dashboard which will contain your map widget.

Add a new map widget by clicking the + button in the upper right corner and selecting Map.

Note:
When creating this widget, do not forget to click the Select Device button and to select your device.
Creating a map widget

Finally, you will see a map widget containing your device’s current location appearing in your dashboard!

LR1110 location