We have gone through introduction to raspberry pi and and basic setup steps in previous blog. Great many automation projects can be built using this SBC. But, main issue with it is not knowing programming languages like Java, python, C / C++ / C#. This is the point where we start loosing interest . So to take care of that, we are going to look into 'Node-RED', an graphically programming tool.
Node-RED is a low-code programming platform for event-driven applications. It is built on Node.js and uses a graphical flow editor to create flows that connect nodes together. Nodes can be used to perform a variety of tasks, such as sending and receiving messages, interacting with devices, and processing data.
Node-RED is a popular choice for developing IoT applications, but it can also be used for other types of applications, such as web applications, data pipelines, and workflow automation.
This blog post will guide you through the steps to install Node-RED on Windows, Linux, and Raspberry Pi.
Before installing Node-RED, you will need to have the following installed on your system:
- Node.js version 14 or higher
- npm
- Git (optional)
Installing Node-RED on Windows
To install Node-RED on Windows, follow these steps:
- Download and install Node.js from the Node.js website.
- Open a command prompt window.
- Navigate to the directory where you want to install Node-RED.
- Run the following command:
npm install -g --unsafe-perm node-red
- Once the installation is complete, you can start Node-RED by running the following command:
node-red
Installing Node-RED on Linux
To install Node-RED on Linux, follow these steps:
- Open a terminal window.
- Update your package manager:
sudo apt update
- Install Node.js and npm:
sudo apt install nodejs npm
- Navigate to the directory where you want to install Node-RED.
- Run the following command:
npm install -g node-red
- Once the installation is complete, you can start Node-RED by running the following command:
node-red
Installing Node-RED on Raspberry Pi
To install Node-RED on Raspberry Pi, follow these steps:
- Open a terminal window.
- Update your package manager:
sudo apt update
- Install Node.js and npm:
sudo apt install nodejs npm
- Navigate to the directory where you want to install Node-RED.
- Run the following command:
npm install -g node-red
- Once the installation is complete, you can start Node-RED by running the following command:
node-red
Starting Node-RED at boot
If you want Node-RED to start automatically when your system boots, you can follow these steps:
On Raspberry Pi:
- Create a new text file and name it
node-red.service
. - Paste the following text into the file:
[Unit]
Description=Node-RED
After=network.target
[Service]
Type=simple
User=pi
ExecStart=/usr/bin/node-red
Restart=always
[Install]
WantedBy=multi-user.target
- Save the file and close it.
- Copy the file to the
/etc/systemd/system/
directory:
sudo cp node-red.service /etc/systemd/system/
- Reload the systemd daemon:
sudo systemctl daemon-reload
- Enable the Node-RED service:
sudo systemctl enable node-red.service
- Start the Node-RED service:
sudo systemctl start node-red.service
On Linux:
- Create a new text file and name it
node-red.service
. - Paste the following text into the file:
[Unit]
Description=Node-RED
After=network.target
[Service]
Type=simple
User=pi
ExecStart=/usr/bin/node-red
Restart=always
[Install]
WantedBy=multi-user.target
- Save the file and close it.
- Copy the file to the
/lib/systemd/system/
directory:
sudo cp node-red.service /lib/systemd/system/
- Reload the systemd daemon:
sudo systemctl daemon-reload
- Enable the Node-RED service:
sudo systemctl enable node-red.service
- Start the Node-RED service:
sudo systemctl start node-red.service