Node-RED tutorial

References

Running Node-RED

If you have installed Node-RED as a global npm package, you can launch node-red in the command prompt (Windows):

C:\>node-red

or in the terminal (Linux):

$ node-red

This will output the Node-RED log to the terminal. You must keep the terminal or command prompt open in order to keep Node-RED running. Note that running Node-RED will create a new folder in your %HOMEPATH% folder called .node-red. This is your userDir folder, think of it as the home folder for Node-RED configuration for the current user.

You can then open the Node-RED graphical editor by pointing your browser at http://localhost:1880

Nodes

A Node-RED program is developed as a FLOW of messages running through a sequence of NODES. Each node can implement an elaboration of the message.

Nodes consist of code that runs in the Node-RED service (javascript .js file), and an HTML file consisting of a description of the node, so that it appears in the node pane with a category, colour, name and an icon, code to configure the node, and help text.

Nodes are added to a flow by simple drag&drop.

A node can be linked to (multiple) input and (multiple) output via its ports which enable messages to be passed between nodes.

If a node has been change after the latest deployment, then it displays a blue circle above it. If there are errors with its configuration, it displays a red triangle.

Some nodes include a button on either its left or right edge. These allow some interaction with the node from within the editor. The Inject and Debug nodes are the only core nodes that have buttons.

A node configuration can be edited by double clicking on the node, or pressing Enter when the workspace has focus. If multiple nodes are selected, the first node in the selection will be edited. The node edit dialog has typically three sections: Properties, Description, Appearance. The Properties section is used to set what the node does.

Wires

Wires define the connections between node input and output endpoints in a flow.

They (typically) connect the output endpoints of nodes to inputs of downstream nodes indicating that messages generated by one node should be processed by the connected node next. It is possible to connect more than one node to an endpoint using wires. It is also possible to connect downstream nodes to upstream nodes to form loops.

When multiple nodes are connected to an output endpoint, messages are sent to each connected node in turn in the order they were wired to the output. When more than one node output is connected to an input endpoint, messages from any of those nodes will be processed by the connected node when they arrive.

How to create wires? Left-click on an output node port and, while holding down the mouse button, move to the destination input node port. Release the mouse button.

Flows

Deploying Flows

Flow Deployment is needed before executing the flow itself. The Deploy button is on the top right corner and changes colour from grey to red when any change has been made to a flow to indicate that in it needs to be deployed. After deployment the flow can be run, e.g. clicking on the button of an Inject node.

Managing Flows

Create a Flow: click on the ‘+’ tab

Delete a Flow: double-click on the flow tab and press the button «Delete»

Rename a Flow: double-click on the flow tab, change the name and press the button «Done»

Import a Flow: click on the main menu and select «Import», «Clipboard». Then copy&paste the flow or select an input Json file.

Export a Flow: click on the main menu and select «Export», «Clipboard». Then copy the flow or download it as a Json file.

Last updated