Skip to main content
All CollectionsConnect your Devices
Connect the WisNode TrackIt (RAK2171) to Ubidots
Connect the WisNode TrackIt (RAK2171) to Ubidots

This article is about connecting RAK’s LoRaWAN GPS tracker to Helium’s LoRaWAN public network server and integrate it with Ubidots platform.

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

Requirements

  1. A mobile cellphone running either Android or IOS with Bluetooth capability.

  2. RAK’s WisNode TrackIt app for Android or iPhone.

  3. An active account on Helium’s public LoRaWAN network server. Here you can sign up for one.

  4. An active account on the Ubidots platform. If you do not have one already, sign up here.

1. WisNode TrackIt Configuration to use the LoRaWAN network

Please open the recently installed “TrackIt” app.

image.png

Click on “Sign in with RAK ID” and the next screen will appear:

image.png

If you already happen to have a “RAK ID” account, please sign in, if not, press the “Create new” link in order to create a new account. To do so, just follow the given steps in the app.

After successfully creating your “RAK ID” account you will be prompted to add your TrackIt device via Bluetooth. At this point, please take your TrackIt device and press the power button for at least 3 seconds in order to make it discoverable by your cellphone’s Bluetooth. A soft pitch sound will confirm that the device in in discoverable mode. The following image shows how your screen should look like at this point:


image.png

After hearing the device’s sound confirmation, press the “Add Tracker” button in order to add and configure your WisNode device. A new screen will pop-up telling you that the device is currently being paired to the cellphone. This process can take about 20 seconds to complete.


Pro tip: If you get a “Tracker not found” error, just turn off your cellphone’s Bluetooth as well as the TrackIt, then turn on everything again.


When the device pairs successfully with the cellphone, a screen will prompt you to set the TrackIt’s name as well as it’s working mode, any name is allowed in this step, for this one does not repercute on the succeeding steps. For the working mode please choose the “LoRaWAN” option, then, options for the type of network will appear. Please choose the “Third Party NS” option. The following picture depicts this situation:

image832.png

By choosing the “Third party NS” option we are making sure that our device is able to connect to any LoRa network.

Up to this point, a new screen will pop displaying the TrackIt’s data such as the device’s DevEUI, it’s Class and of most significance, the LoRaWAN band region. It is mandatory to store the device’s data because those are the parameters which will be used to register the device on the Helium console in later steps. In the following screenshot, the red boxes indicate the data that will be used later on the registration step, so please store this information carefully.


image82666.png

You will notice a drop-down menu displaying the name “REGION”. This is the most important step, here you need to select the appropriate band region accordingly to your country regulations and the allowed spectrum for applications. Here, one of our partners briefly lists some countries along with their allowed region bands.

The country in which this article was developed allows the use of the AU915 band, so we will select AU915.


bitmap.png

After pressing the “CONFIRM” button a screen alert will pop-up, ignore it and click the “CONFIRM” button again to proceed to the next step.


Now the device is ready to be registered on the Helium LoRa network!

2. Registering the TrackIt on Helium’s public LoRa network

Log in into the Helium's console by following this link. Then, head over to the menu on the left side, specifically the “Devices” section.

rect18125.png


There, click on the “Add New Device” button. It is the one enclosed by a red box in the following image:

image18647.png

After clicking on the “Add New Device” you’ll be taken to another web page which will prompt you to enter the device’s unique data such as its DevEUI, AppEUI and AppKey. Get this data from the location in which you stored it at step 1 of this guide, enter each data on the corresponding field and then click on “Save Device”. The next image shows how to register a new device. Please leave the “Profile” option as it is by default and give your device a describing name.

image24849.png

Pro tip: You can attach your device with a specific label if you wish to use this integration settings on other devices.


3. Creating the decoder function

Now with our device being registered on Helium’s public LoRa network, it should start sending data to the network server in the form of a JSON object according to Heliums JSON schema, this object contains lots of information such as the device’s DevEUI, the hotspots through which the data reached the network server, it’s ID, and mostly important, the payload, which is usually a Base64 coded string. We need to extract the data from this payload by making use of a decoder function.

Let’s head over to the “functions” section at the left side panel, then click on “Add new function”,select the “Custom” option and give it an appropriate name. You might name it as “my device decoder function” but that is entirely up to you. Here is a GIF to explain the process better.

Now, copy the following decoder in the code editor, then click on the “Save changes” button.

function Decoder(bytes,port) {

if(bytes[0] == 0xCA)
{
// No Location fix
timeStamp = ((bytes[11] << 24) | (bytes[12] << 16) | (bytes[13] << 8) | bytes[14]) * 1000;
var payload =
{
"location-fixed":{
"value":0,
"timestamp":timeStamp
},
"battery":{
"value":bytes[10],
"timestamp":timeStamp
},
"position":{
"value":1,
"timestamp":timeStamp,
}
};
return payload;
}
else if(bytes[0] == 0xCB)
{
// Location fix
timeStamp = ((bytes[21] << 24) | (bytes[22] << 16) | (bytes[23] << 8) | bytes[24]) * 1000;
lng = (((bytes[10] << 24) | (bytes[11] << 16) | (bytes[12] << 8) | bytes[13]) * 0.000001).toFixed(4);
lat = (((bytes[14] << 24) | (bytes[15] << 16) | (bytes[16] << 8) | bytes[17]) * 0.000001).toFixed(4);

var payload =
{
"location-fixed":{
"value":1,
"timestamp":timeStamp
},
"battery":{
"value":bytes[20],
"timestamp":timeStamp
},
"position":{
"value":1,
"timestamp":timeStamp,
"context":{
"lat":lat,
"lng":lng
}
}
};
return payload;
}

}

4. Creating the integration between Helium and Ubidots

With the data already being decoded, we just need to think about how to make this data get to the Ubidots platform, if you are already familiar with Ubidots, you may think about making HTTP requests or using MQTT protocol manually to achieve such a goal, however, luckily for all users our there, Ubidots and Helium teams have thoroughly thought about this. For so, we provide you with the Ubidots Integration on the Helium platform, which is a tool that will set up an endpoint and... long story short: manage the data flow between Helium and Ubidots.

To create the integration, please head over to the “Integrations” section at the left side panel. Then the following page will load on your browser. There, click on the “Add New Integration” button and select the “Ubidots” option.

After clicking on the Ubidots Integration icon, another web page will be displayed with 2 different buttons: one that opens the integration documentation and the other one having the text “+ Add Integration”, click on this option and the following page will be displayed:

Please enter an Ubidots token on the “Enter Auth Token” field and then click the “Get Webhook URL” button. If you happen to have forgot what and where is your token, please refer to the pertinent information for this matter.

After writing down your token on the corresponding field and pressing the “Get Webhook URL” button, a field corresponding to the integration name will be displayed for you to fill, please do so and then click the “Add Integration” button under the text box for the name.


5. Connecting the integration

The integration is now created, what’s next is to tell Helium which device will use this new integration and where to use the decoder function. To do so, please go to the “Flows” section on the left side panel. In order to connect the integration to our device, we’ll just have to, literally, connect the dots. While on the “Flows” section, head over to the “NODES” panel in the upper left corner, click on it and then go to the “Devices” lid, there you will have to look for the device created on step 2 and just drag and drop onto the blank space. Do the same thing on the “integrations” lid, drag and drop the recently created integration into the blank area. Finally, do exactly the same, just that this time you’ll have to search on the “Functions” lid for the decoder created on step 4. At last, just connect the nodes.

Since "a picture is worth a thousand words", here's a GIF depicting the process:


There only remains one last step before you can send your TrackIt’s data to Ubidots, that is to set up the decoder from the Ubidots side. To do so, please head over to your Ubidots account, then go to the “Plugins” section under the “Devices” tab. Look for the recently created plugin from the Helium console.

Click on the gray pencil icon at the right side of the plugin name to edit it’s decoder function.

banner.png

A new web page will start to load. Get to the left side panel and look for the “Decoder” section, click on it and then your screen should look like this:

Notice that there is already a written function, feel free to delete all that code there and paste this one:

def format_payload(args):

# Log received data for debugging purposes:
print(args)
decoded_payload = args["decoded"]["payload"]
print(decoded_payload)
return decoded_payload

After pasting the code in the code editor, click the “SAVE & MAKE LIVE” button to save the changes and let the plugin run.


Pro tip: You can use the “Logs” section in order to debug your plugin by taking a look at the responses logs.


6. Visualizing the data on the Ubidots platform

If you head over to the “Devices” section of you Ubidots account, you will notice that a new device has been created with the name of the device created in step 2 of this guide. Click on it and you will see 3 variables. You can set the device’s location by a specific variable, in this case, the position variable will be selected from the “Mode” drop-down menu.


banner.png

Now you can create a dashboard to have a better data visualization. Here is a snapshot of what you can do:

Other users also found helpful...

Did this answer your question?