Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Info
Excerpt

Node-RED is fun little tool from IBM Research to "wire up the IoT". We show how you can use it to interface it to your SmartMesh IP network without writing a line of code!


Table of Contents

Overview of Node-Red

Node-RED is fun tool from IBM Research to "wire up the IoT". It's a little program you launch of your computer, which allows you link inputs (sensors, etc.) to outputs (actuators, files, Twitter feeds etc) through a web-based graphical interface.

...

Info
titleRequirements

To replicate this tutorial, you need to have:

We assume the motes are running the default firmware, in Master mode.

We assume the manager is connected your computer over USB, and that all the motes are switched on and have joined the network.

We assume you have downloaded the SmartMesh SDK, and are comfortable enough with it that you can launch different applications.


Installing Node-RED

The first step is to install Node-RED.

...

Tip

Following the excellent Getting Started guide if you want to learn more about Node-RED.

Receiving temperature data on Node-RED

Our first Node-RED "flow" (the connections between inputs and outputs, in Node-RED parlance) is to receive temperature data generated by SmartMesh IP motes directly in Node-RED. We will use for that the PublishToWeb sample application of the SmartMesh SDK.

Gliffy
imageAttachmentIdatt110309987
name

...

node-red_flow1
diagramAttachmentIdatt110309983

Start the PublishToWeb SmartMesh SDK sample application

Tip

The PublishToWeb sample application is part of the SmartMeshSDK.

...

You will see a line print each time the application receives a temperature reading from one of the motes.

Creating the Node-RED flow

Drag and drop the following "nodes" to build the following flow:

...

Tip

The following code is the textual representation of the Node-RED flow above. You can simply paste this in the "Import > Clipboard" utility in Node-RED:

Code Block
[{"id":"800ce651.8f7898","type":"inject","z":"4e9083b3.53976c","name":"led on","topic":"","payload":"1","payloadType":"num","repeat":"","crontab":"","once":false,"x":134.13352966308594,"y":211.97726440429688,"wires":[["b37b4d77.dd1b1"]]},{"id":"b79f9dbc.87d2a","type":"http request","z":"4e9083b3.53976c","name":"","method":"POST","ret":"txt","url":"http://127.0.0.1:8080/","tls":"","x":552.1447601318359,"y":275.53692626953125,"wires":[[]]},{"id":"b37b4d77.dd1b1","type":"function","z":"4e9083b3.53976c","name":"","func":"msg.headers = {\n    \"Content-type\" : \"application/json\"\n}\nmsg.payload = {\n    \"mac\": \"00-17-0D-00-00-38-03-ca\",\n    \"state\": msg.payload\n}\nreturn msg;","outputs":1,"noerr":0,"x":336.1334991455078,"y":283.875,"wires":[["b79f9dbc.87d2a"]]},{"id":"74496dc3.b9f754","type":"inject","z":"4e9083b3.53976c","name":"led off","topic":"","payload":"0","payloadType":"num","repeat":"","crontab":"","once":false,"x":141.1420440673828,"y":364.9715881347656,"wires":[["b37b4d77.dd1b1"]]}]

Blinking LEDs from Node-RED

The goal of this Node-RED flow is to toggle the mote's LED by click on the Node-RED interface:

Gliffy
namenodered_flow2

Start the JsonServer SmartMesh SDK sample application

Tip

The JsonServer sample application is part of the SmartMeshSDK.

Code Block
JsonServer - SmartMesh SDK 1.0.8.142 (c) Dust Networks

serial port of SmartMesh IP Manager (e.g. COM15): COM31
ok. connected to manager at COM31
ok. JSON server started on port 8080

Create the Node-RED flow

Drag and drop the following "nodes" to build the following flow:

...

Tip

The following code is the textual representation of the Node-RED flow above. You can simply paste this in the "Import > Clipboard" utility in Node-RED:

Code Block
[{"id":"51558b9b.062cd4","type":"http in","z":"f29e7b87.9fe988","name":"","url":"/api/v1/oap","method":"post","swaggerDoc":"","x":313.13633728027344,"y":263.14202880859375,"wires":[["f72fa70d.324a98","17fc38a7.92de37"]]},{"id":"f72fa70d.324a98","type":"debug","z":"f29e7b87.9fe988","name":"","active":true,"console":"false","complete":"req.body","x":598.1391754150391,"y":216.09942626953125,"wires":[]},{"id":"17fc38a7.92de37","type":"http response","z":"f29e7b87.9fe988","name":"","x":512.1420135498047,"y":303.9090881347656,"wires":[]}]

Where next?

This tutorial has shown you how to send data from your SmartMesh IP network into Node-RED, and from Node-RED into your SmartMesh IP network.

...