This post is an introductory guide to Node-RED. I’ll cover what’s Node-RED, how to install it, how to use the visual interface to create a simple flow.
Before you start reading this blog post, I’m making an assumption that you are already familiar with the Raspberry Pi and you know how to install the operating system.
If you don’t, please read this blog post: Getting Started with Raspberry Pi. By the end, you should have Raspbian or Raspbian Lite installed in your Raspberry Pi.
If you like the home automation and you want to learn more about Node-RED, Raspberry Pi, ESP8266 and Arduino. I recommend that you download my course: Build a Home Automation System for $100.
Let’s get started!
Node-RED is a powerful open source tool for building Internet of Things (IoT) applications with the goal of simplifying the programming component.
It uses a visual programming that allows you to connect code blocks, known as nodes, together to perform a task.
The nodes when wired together are called flows.
Why do I think Node-RED is a great solution?
Node-RED is open source and developed by IBM.
The Raspberry Pi runs Node-RED perfectly.
With Node-RED you can spend more time making cool stuff, rather than spending countless hours writing code.
Don’t get me wrong. I love programming and there is code that needs to be written throughout this course, but Node-RED allows you to prototype a complex home automation system quickly.
What can you do with Node-RED?
Node-RED makes it easy to:
- Access your RPi GPIOs
- Establish an MQTT connection with other boards (Arduino, ESP8266, etc)
- Create a responsive graphical user interface for your projects
- Communicate with third-party services (IFTTT.com, Adafruit.io, Thing Speak, etc)
- Retrieve data from the web (weather forecast, stock prices, emails. etc)
- Create time triggered events
- Store and retrieve data from a database
Here’s a library with some examples of flows and nodes for Node-RED.
Getting Node-RED installed in your Raspberry Pi is quick and easy. It just takes a few commands.
Having an SSH connection established with your Raspberry Pi, enter the following commands to install Node-RED:
pi@raspberry:~ $ bash <(curl -sL https://raw.githubusercontent.com/node-red/raspbian-deb-package/master/resources/update-nodejs-and-nodered)
The installation should be completed after a couple of minutes.
Autostart Node-RED on boot
To automatically run Node-RED when the Pi boots up, you need to enter the following command:
pi@raspberry:~ $ sudo systemctl enable nodered.service
Now, restart your Pi so the autostart takes effect:
pi@raspberry:~ $ sudo reboot
Testing the Installation
When your Pi is back on, you can test the installation by entering the IP address of your Pi in a web browser followed by the 1880 port number:
In my case is:
A page like this loads:
Let’s take a look at the Node-RED visual interface.
On the left-side, you can see a list with a bunch of blocks. These blocks are called nodes and they are separated by their functionality. If you select a node, you can see how it works in the info tab.
In the center, you have the Flow and this is where you place the nodes.
Creating a simple flow
Let’s test a simple example of a flow. Start by dragging an Inject node to your flow. Then, also drag a Debug node.
Connect your nodes together. You can drag them to confirm that they are connected.
Now, let’s edit the inject node. Double-click the node. In the figure below you can see different settings you can change.
Select string and type Hello!.
To save your application, you need to click the deploy button on the top right corner.
Your application is saved.
Testing the flow
Let’s test our simple flow. Open the debug window and click the Inject node to trigger the “Hello!” string.
As you can see, our message is being printed in the debug window. This is a very basic example and it doesn’t do anything useful. However, the purpose of this post is to get you familiar with the Node-RED interface.
This post is a quick guide to setup Node-RED on a Raspberry Pi and create a simple flow. I’ll be posting future tutorials doing things with a real world application, but I thought it would be useful to introduce this software first.
Like home automation? Learn more about Node-RED, Raspberry Pi, ESP8266 and Arduino with my course: Build a Home Automation System for $100.
Do you have any questions? Leave a comment down below!
Thanks for reading. If you like this post probably you might like my next ones, so please support me by subscribing my blog.