Hey All,
Today we're going to look at turning your Sigfox data into a human readable form that you can easily use in your applications. Before we start, have a look at the How To Integrate Any Sigfox Device With Wia tutorial to get your devices connected to Wia.
For this tutorial, my Event data will contain the hexadecimal string aabbccdd
. We will show how to convert this to binary, take the first 6 bits as our temperature reading and create a new Event.
Create a Flow
- Go to the
Flows
and clickCreate Flow
. - Enter a name for your
Flow
. I'm going to call mineTranslate Sigfox Data
. - You will then be redirected to the Flow Studio.
Add a Trigger Node
- In the Flow Studio, drag over an Event trigger node from the panel on the left.
- Select the node, enter
sigfoxDataUplink
as the name of the Event in the panel on the right and clickUpdate
.
Add a Logic Node
- Drag over a
Run Function
logic node from the panel on the left. This node allows you to inject your own Javascript and manipulate the data flowing through. - Copy the code below into the
Code Block
and clickUpdate
.
let sigfoxData = event.data.sigfoxData;
let binaryData = parseInt(sigfoxData, 16).toString(2);
let tempBinary = binaryData.slice(0, 6);
let result = parseInt(tempBinary, 2).toString(10);
event.data = result;
Add an Output Node
- Drag over an
Event
output node from the panel on the left. - Enter
temperature
as the name of the Event.
Connect the Nodes
- Click on the white diamond shape at the bottom of the Event node and drag the line to the input of the Logic node.
- Click on the white diamond shape at the bottom of the Logic node and drag the line to the input of the Output node.
Add Flow to Your Device
- Go to
Devices
and select the Device your would like to add the Flow to. - Click on
Flows
in the subnav then click onEnable
beside the Flow name.
Run the Flow
Publish an Event from the Device and you will see the new temperature
Event come through.
(Optional) Create Multiple Events in the Same Flow
If you wish to create multiple events, just follow the previous steps for your other data points.
That's all folks!
P.S. If you need any help with getting setup, tweet us or email support@wia.io
References
Sigfox is a French Internet of Things (IoT) company founded in 2009 that builds wireless networks to connect low-energy narrowband objects such as electricity meters, smartwatches, and washing machines, which need to be continuously on and emitting small amounts of data.
Top comments (0)