Getting Started with Siguino and Wia.io

Device Registration

The Siguino is registered as a Sigfox DevKit, so once you have received your Siguino you can activate it as a DevKit (one year’s free messages) by following the instructions at this address:

buy.sigfox.com/activate

Once registered and powered (either by a standard 3v CR2 battery, or via the onboard pins), you should be able to navigate to the Sigfox backend and see messages arriving here:

backend.sigfox.com

One at the above address, click “Device Type” then click the name of the registered device in the table listed, followed by “Associated Devices” on the left hand menu, then click the Device ID in the table listed and finally “Messages” in the left hand menu.

Wia Integration

Wia.io is a great way to quickly make use of the data being sent by the Siguino.  Head over to Wia and create a free account and once done, follow the sample instructions here to get your Siguino to send message data on to the Wia platform:

https://developers.wia.io/docs/integrations-sigfox

Once you have the devices registered on Wia, you can put together a “Flow” so that whenever new messages come through from the device you can decode the packet and do something useful with the data (e.g. send an email with the temperature recorded, etc). That process is well described here:
e.g. a flow to extract and send temperature data might look like this:

Javascript Code for Data extraction

The Siguino data is bit packed into the 12 bytes allowed on the Sigfox network so to make using the Wia flow simpler, here’s a snippet of javascript code you can use to easily extract the data you need from the bit packed message the Siguino sends (simply replace the field selection at the bottom of the code with the name of the field you want to use as defined at the top):
var SiguinoFields = {
SEQ_NUM: [0,8],
TEMPERATURE: [8,15],
LIGHT_AVG: [15,25],
SHOCK_OCCURRED: [25, 26],
MAG_OCCURRED: [26, 27],
BATT_LVL: [27, 31],
PRESSURE: [31,39],
HUMIDITY: [39,46],
ALTITUDE: [46,55]
};

function reverse_string(s){
return s.split("").reverse().join("");
}

function hex2bin(hex_val) {
var returnValue = ''; // Empty string to add our data to later on.

for (var i = 0; i < parseInt(hex_val.length / 2); i++) {
// Determining the substring.
var substring = hex_val.substr(i*2, 2);
// Determining the binValue of this hex substring.
var binValue = parseInt(substring, 16).toString(2);

// If the length of the binary value is not equal to 8 we add leading 0s (js deletes the leading 0s)
// For instance the binary number 00011110 is equal to the hex number 1e,
// but simply running the code above will return 11110. So we have to add the leading 0s back.
if (binValue.length != 8) {
// Determining how many 0s to add:
var diffrence = 8 - binValue.length;

// Adding the 0s:
for (var j = 0; j < diffrence; j++) {
binValue = '0'+binValue;
}
}

// Adding the binValue to the end string which we will return.
returnValue += binValue;
}
// Returning the decompressed string.
return returnValue;
}

function get_siguino_value(siguino_data, field_name){
if ((siguino_data.length%2)==1) siguino_data = "0" + siguino_data;
var binary_data = hex2bin(siguino_data);
var reversed = reverse_string(binary_data);
var binary_value = reverse_string(reversed.slice(SiguinoFields[field_name][0], SiguinoFields[field_name][1]));
//console.log(binary_value);
var result = parseInt(binary_value, 2);
if (field_name=="TEMPERATURE") {
result /= 2;
}
return result;
}

let sigfoxData = event.data.sigfoxData;
let result = get_siguino_value(sigfoxData,"TEMPERATURE");
output.body.data = result;