Skip to main content

Ubidots Integrated(via Helium)

This article will illustrate the process of connecting the SenseCAP T1000 Tracker to Ubidots through Helium LNS.

Written by Juan David Tangarife - From Ubidots Team

Source

pir

Requirements

An Ubidots active account A SenseCAP T1000 Tracker An active account in the Helium console with some DC An cellphone supporting either Google Play Store or AppStore as well as Bluetooth.

Install SenseCAP Mate app and configure the tracker

Scan the following QR code. It will take you to Seeed Studio's SenseCAP Mate app official download page.

pir

Once it is installed, enable the Bluetooth on your cellphone and launch the app. If you don't have an account already, you will have to register to use the app.

After that, press and hold the tracker's button for at least 3 seconds or until the LED starts flashing. Then, from the list of devices, select Tracker T1000

pir

Tap on your device:

pir

Go to the settings tab and then LoRa tab. There select as platform Helium and select the Frequency plan according to your requirements, also, make sure to copy the Device EUI, APP EUI and APP Key for you are going to need it in later steps. Once finished, tap the Send button to save the settings.

pir

Register the tracker on Helium LNS

Log into your Helium console, then, go to “Devices” section and click on “Add device” button

pir

Fill the required fields such as the device name, the LoRaWAN credentials, etc. Then click the Save Device button.

pir

Create the decoder function on Helium

The next step is to setup the function that will decode the raw bytes into a human readable form. Head to Function tab on the panel at the left side. Then click the Add New Function button and give it a name:

pir

Seeed Studio provides a decoder specifically for this device on the following repository. Paste that decoder on the text field and then save the changes.

Create the integration to Ubidots

Go to the Integrations section, then click on Add integration and search for the Ubidots integration:

pir

Click on +Add integration

pir

Enter your Ubidots token in the respective field, then click on the Continue button and wait for the confirmation pop-up message. After that, name your integration and click the Add Integration button:

pir

After performing this step, a new Helium plugin will be created on your Ubidots account.

Create the flow to connect the integration to Ubidots

Head to the Flows section, then, from the drop-down menu at the top left corner, drag and drop the device, the decoder function and the integration into the blank area, then join the dots together as the GIF below shows:

pir

In this example, both the device and the decoder function are called "sensecap-lorawan-tracker", and the integration is called "send data to ubidots".

Since the JSON object returned by Seeed Studio's decoder is not compatible with the Ubidots schema, a transformation is needed after extracting the data of interest.
Head to the decoder section of your Helium plugin, delete all the code there and replace it with the following one:

#Set to true in order to enable hotspot information
HOTSPOT_INFO_ENABLE = False

def format_payload(args):

messages = args.get("decoded", {}).get("payload", {}).get("data", {}).get("messages", [])
ubidots_payload = {}

error = assert_error(messages[0][0])
if error is not None:
return error

if HOTSPOT_INFO_ENABLE:
hotspot_info = args.get('hotspots', None)
ubidots_payload['SNR'] = hotspot_info[0].get('snr') if hotspot_info is not None else None
ubidots_payload['RSSI'] = hotspot_info[0].get('rssi') if hotspot_info is not None else None
ubidots_payload["port"] = args.get("port", None)
ubidots_payload['Frame Counter'] = args.get('fcnt', None)

for msg in messages:
for sensor in msg:
message_type = sensor.get("type", None)
value = sensor.get("measurementValue")
if message_type == "Latitude" or message_type == "Longitude":
position = ubidots_payload.setdefault("position", {})
position.update({message_type.lower(): value})
continue
elif message_type == "Timestamp":
ubidots_payload["timestamp"] = value
continue
ubidots_payload[message_type] = value

print(ubidots_payload)
return ubidots_payload


def assert_error(data : dict):
if "error" in data:
return {"ERROR" : { "value" : data["errorCode"], "context" : { "status" : data["error"]}}}
return None

If everything got wired up correctly, you should be seeing this on a newly created device on Ubidots

pir

Loading Comments...