Node-RED is a visual code editor for “wiring the Internet of Things”

Node-RED is a tool for wiring together hardware devices, APIs and online services in new and interesting ways.”   Node-Red is also the preferred web service wiring tool for IBM® Watson™ IoT Platform and IBM Bluemix®.  Node-Red is also used at the edge in the Multitech AEP MultiConnect® Conduit™ gateway, see an interesting example here.

If you haven’t played with Node-RED yet, we recommend you give it a try.

Node-RED is great at wiring services together but in many cases you will want to quickly do data transforms, apply complex business rules, add new web services and interactive user experiences to Node-Red.  One easy way to do this is with  In this first of a series of blog posts we will show you how to install Node-Red and integrate  Follow on blog posts will demonstrate with IBM Bluemix® and the Multitech gateway.

Let’s start…

Installing and testing is as easy as running an npm install command and launching the web app.

$ sudo npm install -g node-red
$ node-red

From there, you’re minutes away from your simple “Hello Node-red” script.

Like other visual code editors, node-red offers a bunch of pre-set nodes that are most typically used: connection types / protocols (tcp, udp, serial, http, websocket, …), connectors (twitter, email) and listeners.

For the purpose of this tutorial we will use two very basic nodes:

  1. Inject: used to simulate injected data (data arriving to the flow)
  2. Debug: a node that prints output to the console

This will result in a simple “Flow” (the solution “unit” name used by node-red which is an assortment of nodes built / connected / wired to fulfill a certain requirement) which will print out the received messages.

Once the node-red webapp is started, open your favorite web browser and go to localhost:1880.

You will find yourself working on a new blank flow named “Flow 1” with a list of nodes on the left.

From the “input” section, drag and drop the “inject” node and from the “output” section add a “debug” node. You should also “wire” them by dragging a connector from one end of the first node to the second (using the ports, the small light square on the edge of each node)


Next, we will configure the “input” node by specifying the payload format and the content. The payload will be a “string” containing a message that will be processed, “Hello Node” in this case.


Now the flow is set to receive messages (simulated by the inject), the next step is to configure it to output the received message. The output will go to the “debug tab” and it will be an exact “pass-through” of the received  “payload”.


The flow is now ready to be used. You just need to “Deploy” it (by clicking the big red visible button on the upper right) and then to test it by clicking on the blue button in your “inject” node. You will see the output in the console at the right of your screen.

Congratulations, you have just created your first flow!

Cool, so what’s next?

Explore, of course! Node-red is so cool that some devices have it embedded! You can check the lora devices from multitech which allow you to run code built and designed in node-red on the device itself.

Node-red has a “function” node which allows you to write your own code, in the comfort of (or lack-of, depending on your persona) simple programming languages.

Just drop a “function” node between the the input and the output and you can transform the payload before passing it to the logger. Your device is now capable of limited processing power allowing it to act upon sensor readings and other data streams.

So have we just found the winning lottery ticket? The solution to all of the IoT problems?

As is often the case, there are considerations to take into account.

Visual programming limitations

A typical limitation in the world of visual programming is that they are generally designed to solve (extremely well) the problem of the non-programmer that wants to solve straightforward scenarios. They are sometimes even designed in such a way to produce an amazing demo but fail miserably when used for a real world scenario, resulting in a spaghetti of wires or a monster block.

In summary, visual programming is the solution as long as someone with programming skills has already prepared the required nodes ahead of time.

Accessibility / Reliability / Scalability / Availability

In all cases, we know that real solutions require a server somewhere, aggregating data and acting upon input from multiple sources and orchestrating different services. Of course, this server/service will need to be reliable, scalable and available. So it looks like the node-red-on-device is missing one component:, the javascript IoT platform.

Any suggestions?

Yes! Small constrained devices should only be doing the minimal processing / filtering of the data they get from the readings on their sensors. The rest should be off-loaded to the orchestration IoT platform which will do the decision making. Some data requires direct reactions, resulting in notifications; others need to be coupled with data from other devices before a decision is made. Most useful data just needs to be formatted and pushed to big data stores for later processing.

Node-red-scriptr node

While is available over multiple protocols that node-red supports, an easier to use node is provided node-red-contrib-scriptr.

While this is still a work in progress, the scriptr node, which is both an input and an output node, will allow the flow to extend its power by executing a script in the cloud and returning the output to the next node as if it was a local request.

First start by installing node-red-contrib-scriptr-node under the node_modules of your node-red installation and restart your node-red instance.

$ npm install node-red-contrib-scriptr-node
$ node-red

Double click on the node to configure it, passing in the name of the script you want to execute and your token (the script parameter is the name you’ve given to your script and the token can be obtained from your settings)

In this case, we will use a simple script that will lookup the geo-location of the originating IP and then return a localized version of Hello Node. The script name is nodered/hello.

You can now execute your flow as you did in the previous example except that the message is now going to be based on your location “Hola Node”