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.
- Go to 'Flows' and click ''Create Flow'.
- Enter a name for your Flow. I'm going to call mine 'Translate Sigfox Data'.
- You will then be redirected to the Flow Studio.
- 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 click 'Update'.
- Copy the code below into the 'Code Block' and click 'Update'.
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;
- Drag over an 'Event' output node from the panel on the left. Enter 'temperature' as the name of the Event.
- 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.
- Go to 'Devices' and select the Device your would like to add the Flow to.
- Click on 'Flows' in the subnav then click on 'Enable' beside the Flow name.
Publish an Event from the Device and you will see the new 'temperature' Event come through.
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 email@example.com
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.