Discovering Node-red Part 1

Trawling around the various Arduino interest sites and blogs I quite often discover some new and very interesting information on some new topics and some not so new but un-known to me.

Sometime ago I'd read about a visual interface called Node-Red for designing IoT information flows and I was interested but didn't have the time to investigate so it was put on the back burner.

I then found out about the very versatile ESP-8266 that is a very inexpensive WiFi adapter for Arduino that comes in several flavours and can host a web page.

Anyway whilst I was searching around for info on the ESP8266 I found an excellent blog by Peter Scargill (here) and on his blog he'd written some posts about a couple of very interesting topics, node-red and Grovestreams.  In this post I'll try to give you a helping hand by describing my efforts to get it all up and running.

My goal was to have the RPi receiving temperature data from an external Jeenode via 868MHz (EU) using a Jeelink plugged into the RPi USB port, this would then be sent to Grovestreams to graph and also have twitter and/or email alerts setup dependent on temp. values.  Please remember though that I'm a beginner at this not an expert so there might be better ways to achieve this....

First - node-red
This software appears to be a visual interface that utilises Node.js which is a platform built on Chrome's JavaScript runtime.  There is an explanation on the node-red web page on installing both node.js and node-red for PCs and the Raspberry Pi.

Step one - installation
I decided to install node-red on My Windows7 PC first and if I could get it working I would brush the dust of my RPi and fire it up, I installed Node.js following the instructions here and then installed node-red, I think the installation is a little tricky unless you're confident using the command window in Windows but follow the instructions and you should be OK.

Step two - Run node-red
Node-red is run from a cmd window, I ran it using "run as administrator" from the right click context menu, when you run it it starts a server on your PC at http://localhost:1880 and this brings up the visual editor for creating your flows.
This is what my flow eventually looked like, I have added some descriptive text after the screen-grab was taken.

The layout shows all the different nodes down the left hand side, the editing window (where the nodes are dragged to) in the middle, the node information and debug output are on the right hand side (not shown).

Each node has a set of properties relevant to its purpose, i.e. if you double click the serial port node you will be able to configure the port details.

These grabs are from the RPi installation, the serial port names on PC install will look slightly different.
First dialog after double clicking
Click the pencil icon to get the config dialog.

Full serial port config dialog
The next node is called a switch node which can direct data to different outputs based on the incoming data, I realised later that I didn't need two nodes as one node can be given two outputs by adding a second rule.
The message from the transmitter contains labels for the temp. values, Greenhouse and Outside, this switch node uses these labels to direct the temp. values towards the matching Grovestream node.
Double clicking on the switch node opens the config dialog and each time you click on the +rule button, bottom left, you will add another decision and output branch.
The message payload is directed to the relevant output but it still contains the label and I want to remove the label so the next "function" node removes the label leaving just the temp. value.
I must admit that this function node took me a while to configure correctly, I can handle a few different programming languages but Javascript is not my favourite, the function basically splits the payload into parts around the ':' these 2 parts are referenced as 0 and 1 in an array and the second part [1] is passed on from the function thus removing the text label.

The input is Greenhouse Temp:20.1 and the output is 20.1

Once the value has been cleaned up it's ready to send off to my Grovesteams account, the Grove node has been written by Peter Scargill and the instructions to install it on Linux/RPi can be found here, for windows I downloaded the source files and placed them in a folder called "grove" in the following location: 

If installed correctly the purple node will appear in the list of nodes on the left hand side and is configured by double clicking.  Peter has a good "how to" guide on his blog here.

End of part one.


Popular Posts

Chronograph update

DIY Chrono Shopping list

Chronograph completed - Finally