How to install Node-RED and AutoStart on boot on Raspberry pi?

Node-RED is a powerful visual programming tool that allows users to easily create applications by connecting different nodes or blocks. It is popularly used in IoT (Internet of Things) to develop applications that connect and control various devices. If you plan to use Node-RED on a Raspberry Pi, install it with an auto-start feature. This article will guide you through installing Node-RED and auto-start on boot on your Raspberry Pi.

install Node-RED and AutoStart on boot on Raspberry pi
Install Node-RED and AutoStart on boot on Raspberry pi

Step 1: Installing Node-RED on Raspberry Pi

To install Node-RED on your Raspberry Pi, you need to open the Terminal and type in the following command:

bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered)code-box

This command will download and install Node-RED on your Raspberry Pi. Once the installation process is complete, you can run Node-RED by typing in the following command:

node-red code-box

This command will start the Node-RED server, and you can access the Node-RED editor by opening your web browser and entering the following URL:

http://localhost:1880code-box

Step 2: AutoStart node-red on boot

To make sure that Node-RED starts automatically on boot, you need to create a service file. A service file is a configuration file that tells the system how to start and stop a particular service. Follow the steps below to create a service file for Node-RED:

1. Open the Terminal and type in the following command to create a new service file:

sudo nano /lib/systemd/system/nodered.Service code-box

2. Type the following code into the file:

[Unit]
Description=Node-RED
After=network.target
[Service]
ExecStart=/usr/bin/node-red
Restart=on-failure
KillSignal=SIGINT
SyslogIdentifier=node-red
[Install]
WantedBy=multi-user. Target code-box

3. Save and close the file by pressing Ctrl+X, followed by Y and Enter.

4. Type in the following command to reload the systemd configuration:

sudo systemctl daemon-reload code-box

5. Finally, type in the following command to enable the Node-RED Service on boot:

sudo systemctl enable nodered.service code-box

That's it! Now Node-RED will start automatically every time you boot up your Raspberry Pi.

Conclusion

This article discussed installing Node-RED and auto-start on boot on your Raspberry Pi. Node-RED is a powerful tool that can be used to create a wide range of applications, and it is especially useful in the field of IoT. The auto-start feature ensures that your Node-RED applications are always running, even after reboots.

4/Post a Comment/Comments

  1. How do I auto-restart Node-RED if it crashes?

    ReplyDelete
    Replies
    1. To auto-restart Node-RED if it crashes, you can use the following commands:

      >Open a terminal window on your Raspberry Pi
      >Type the command "sudo nano /etc/systemd/system/nodered.service"
      >Add the following line under the "[Service]" section: "Restart=always"
      >Press Ctrl+X to exit, then Y to save changes
      >Type the command "sudo systemctl daemon-reload"
      >Press Enter

      This will configure the Node-RED service to automatically restart if it crashes.

      Delete
  2. Small errors that needs correction

    1. Open the Terminal and type in the following command to create a new service file:

    sudo nano /lib/systemd/system/nodered.Service (Should be "nodered.service)

    2. Type the following code into the file:

    [Unit]
    Description=Node-RED
    After=network.target
    [Service]
    ExecStart=/usr/bin/node-red
    Restart=on-failure
    KillSignal=SIGINT
    SyslogIdentifier=node-red
    [Install]
    WantedBy=multi-user. Target (Should be "muti-user.target")

    ReplyDelete

Post a Comment