Sigfox wide-area, low power devices and Ubidots are a simple to integrate IoT solution from device to application. Track cars, buses, containers, trashcan, or even your golf-bag. Keep track of cattle or take your Sigfox device togo and explore the great outdoors.
In this tutorial we will be using UbiFunctions, a feature tool of Ubidots IoT application development platform.

Requirements  

Setup:

  1. About setting up Suntech ST730 
  2. Ubidots Function Configuration 
  3. Sigfox Callback Configuration 

I. About setting up the Suntech ST730 

The Suntech ST730 is a portable device equipped with Sigfox technology, the GNSS location, Wi-Fi, and a set of sensors — making it a nice option for out-of-the-box asset tracking. This module lets users manage data when needed, preventing excess energy consumption with efficient time-outs. 

This guide is does address the set up of the Suntech ST730 nor its possible configurations; instead, we will be showing a few good set-up practices for building a highly accurate GPS application.

Note: Ubidots is committed to helping you connect your ST730 to our IoT and cloud application platform the easiest way possible. With more guides arriving all the time, see UbiFunctions for more data analytics functions to pair or enhance your applications.

Suntech ST730 GPS Set-up Tip:

Data format for GPS in this tutorial is:

  • 4 bytes for latitude
  • 4 bytes for longitude

Both latitude and longitude are coded using the IEEE- Standard 754 floating point format. If a GPS reading doesn't follow this format, no data reading will be sent. Here's an example of a GPS reading properly done: 

Example: 02c1b6c81cc23c5514 

  • 0x02   – data type
  • 0xC1B6C81C   – latitude -> -22.84771
  • 0xC23C5514   – longitude -> -47.083084

See the SuntechST730 User Manual for additional instructions or troubleshooting to your hardware's setup.

Once you have setup the module to send data —as shown above—, we will now configure the UbiFunction

2. UbiFunction Setup

Note: a Function is a Node.js cloud function executed when a HTTP GET or HTTP POST request is made in the Function's URL as illustrated below. 

  1. For creating a Function go to your Ubidots account -> Device Management -> Functions. NOTE:  If you cannot see the Functions module in your account's menu, you will need to enable the add-on for $29/month in the billing section of your account

2. Click the blue plus icon in the upper-right corner to create a function: 

3. Assign a name to the Function e.g. "suntech-ubidots", to identify it in the Sigfox backend later. 

4. Assign the POST as the HTTP method from the scrollbar.
 
5. Click on "Make it live" to generate an API endpoint URL containing the name of your function. The URL should look like this:

6.  Now,  just copy and paste the code below into the UbiFunction Editor. When pasted, assign your Ubidots TOKEN where indicated:

var request = require('request-promise');
var token = "xxxxxxxxxxxxx"; // Assign your Ubidots TOKEN

async function main(params) {

    var device_id = params.device_id;

    var buf = new Buffer(params.data, 'hex')

    console.log(buf);

    var msg_type = buf.readInt8(0);

    if(msg_type == 2){

        var lat = buf.readFloatBE(1);

        var lng = buf.readFloatBE(5);

        console.log(lat);

        console.log(lng);

    }

    // Build payload

    var payload = {"position": {"value":"1", "context":{"lat": lat, "lng":lng}}};

    // Make POST request to Ubidots

    var post_response = await ubidotsPost(token, device_id, payload);

    // Pass Ubidots' API response to the functions' response

    return post_response;

}

async function ubidotsPost(token, device_label, data) {

    var options = {

        method: 'POST',

        url: 'https://industrial.api.ubidots.com/api/v1.6/devices/' + device_label + '?force=true',

        body: data,

        json: true,

        headers: {

            'Content-Type': 'application/json',

            'X-Auth-Token': token

        }

    };

    return request.post(options);

}


For running a function test, please paste this code in the editor that popups: 

{"device_id": "12345", "data": "02c1b6c81cc23c5514"} 

3. Sigfox Callback Configuration  

Click here for an intro and docs to configure a call in the Sigfox backend with your Suntech device. For this, you will need to use the parameters listed below. 

  • Type: DATA   - UPLINK 
  • Channel: URL 
  • Custom payload config: Leave it in  blank
  • Url pattern: https://parse.ubidots.com/prv/iotexpo/suntech-ubidots (this is the URL generated by the Ubidots parser in the step above)
  • Use HTTP method: POST
  • Header: X-Auth-Token - {Assign_your_ubidots_token} 
  • Content Type: application/json  
  • Body:
{
  "device_id": "{device}",
  "data":"{data}"
}

When the callback is executed properly, your Sigfox backend will look similar to this: 

2. Press "OK" to save all the changes and visualize your new device in Ubidots.

With this, your Sigfox callback is ready and the Ubiparser is properly transforming data received to Ubidots cloud. Now it is time to develop your application with Ubidots code-free IoT application tools.

Go to the Device section and see a newly created device with the ID of Suntech Device as name: 

 
Ubidots is an Internet of Things (IoT) Application Development Platform that empowers system integrators and innovators to launch control, monitoring, and automation applications that turn sensor data into actionable insights. Hiring an engineering team to merge the physical world with a digital world and create an IoT application that both functions and looks great is costly in both time and money, so we did it for you. Ubidots exists as an efficient and economical resource to develop private cloud-based IoT applications and integrate data-driven solutions into enterprises and research.

  


Did this answer your question?