Wirepas Wirepas Blog The Product Marketing guy did what???

February 5, 2019

The Product Marketing guy did what???

By Richard Kinder

Having used Node-RED on a RaspPI to automate my brother-in-law’s cold brew coffee process (trust me it tastes great - take a look at https://www.crudedrinks.co.uk/ and buy some today!) I wondered how long it would take to create a Node-RED flow that received data from a Wirepas Mesh powered battery operated sensor node and displayed the data on my PC. This seemed like the kind of thing someone evaluating Wirepas Mesh might want to do, so how long will it take?

Node-RED is a wonderful environment for wannabe developers in product marketing to feel empowered. The added benefit is that the node.js runtime can be deployed anywhere – edge, cloud or developer’s workstation and is simple enough even for a product marketing guy to use!

So, with a little help from my friends and colleagues in the Wirepas Grenoble office I set out to see. The results may surprise you.

With the clock ticking we got to work. The story unfolds as below, keep in mind that this was done as a side-project whilst we all worked on our day jobs:

Tuesday 13:39 – Request made to Grenoble team to create a quick application running on a partner’s nRF52 based sensor device running on the Wirepas Mesh stack.

Tuesday 15:46 – Node programmed and on-line. Data flowing to the gateway device (in this case a Raspberry Pi running our reference Linux gateway software) and being sent as protobuf payload over MQTT/S to a broker running in the cloud.

Tuesday 15:49 – MQTT credentials, certificate and topic received from the team in Grenoble. Payload format – monotonically increasing 4-byte hex value described (this may seem like a trivial detail but I will come back to this later) and proto files received describing the way data is encoded in the MQTT topic.

Tuesday 18:49 – Node-RED fired up on my PC and appropriate node.js packages installed: node-red-contrib-protobuf (to convert the protobuf payload to a JSON object for native use in Node-RED) and node-red-dashboard (to create a web-based visualisation of the data).

Tuesday 19:02 – Figured out that the generic_message.proto definition (part of our Linux gateway software package) needs to be configured to the protobuf node, which allows the protobuf payload to be correctly decoded and the payload now appears in a JSON object for native use in Node-RED. Eureka!

Tuesday 19:23 – So the gateway is sending a little-endian byte array in the protobuf payload that looks like this 'data_payload': b'\x0f\x00\x00\x00' but the protobuf node output is “fwMAAA==". What’s going on – there’s something strangely familiar about the protobuf node output, can’t quite put my finger on it…I ask a colleague – he agrees it’s familiar, but we don’t conclude on an answer. Vexation!

Tuesday 19:58 – After puzzling over the data format problem for a while and cursing my rusty programming skills, I am overall happy with the ease to set up a flow that receives data from the MQTT broker but perplexed that the payload is mangled between sensor and MQTT broker in the cloud. Time for a cup of tea and getting the kids to bed.

Wednesday 17:08 – Following a day of meetings in London, I returned home with a hunch that the protobuf node is outputting a base64 encoded string. This is confirmed in a quick call with one of my colleagues. So now I install the node-red-node-base64 package to decode the base64 encoded payload and add it to the flow. Double Eureka! Now I see a little-endian hex byte array, I’m getting there…

Wednesday 18:13 – After a bit of Googling, I am “reminded” that there is a JavaScript function that is specifically designed to read a little-endian hex byte array and convert it to an integer value. Added this one line of JavaScript code to a function node. And we are there:

Blog pc 1 Richard

The simple flow to achieve this is in Node-RED ends up looking like this:

Blog pc 2 Richard

So, to answer the question posed at the beginning, how long did this take? Well, in elapsed time from original idea to working solution it took 29 hours. In that 29 hours the total effort was less than 3 hours to get data flowing from battery operated sensor over the Wirepas Mesh to a visualisation dashboard.

In some respects, I had a number of advantages:

  • Existing familiarity with the Node-RED environment
  • Access to great colleagues in the Wirepas R&D team and Grenoble office to develop the custom application for the sensor, brainstorm and troubleshoot with

However, this has to be balanced against my handicaps:

  • I am nowadays in marketing
  • I was multi-tasking this with my day job

What are the lessons learnt in this exercise:

  • If I can do it, then anyone can with some basic know-how
  • Wirepas Mesh is simple to use, especially combined with our Linux gateway software sending data to a MQTT broker in the cloud
  • Data format conversions can be problematic and attention needs to be paid to this topic during development.

Our goal is to very soon make evaluating Wirepas Mesh this simple for real world use cases, including live sensor data by showing how our core product offering can be used with reference code and open source software such as Node-RED and MQTT.

If you are inspired by this story to try Wirepas Mesh for yourself, please get in touch with us at https://wirepas.com/contact-us/.

Watch this space for exciting announcements as we make Wirepas Mesh much easier for people to use, even if they are in product marketing!