Installing Node-Red on a Raspberry Pi

avatar
(Edited)

Today I would like to go over how to install the Node-Red software on your Raspberry Pi. The Raspbian Operating System comes with Node-Red, but I'm not sure what version, or if it includes the Raspberry Pi nodes, so I like to use the script that I had referred to in post 6 of the home automation series. If you haven't read the home automation series, here is the link to post 1

You can access the Pi specific information from Node-Red here and simply run the script:
image.png

I find it easiest to open a web browser on the Pi that I'm upgrading and copy and paste it so I don't make any mistakes:
image.png

It should open up like this:
image.png

Just make sure to answer "Y" to installing the Pi specific nodes:
image.png

And the install make take a few, or quite a few minutes to complete:
image.png

If you read further on the Node-Red Pi page..... you did read the page (grin)? You'll see the command to ensure Node-Red autostarts when the Pi boots, and once it runs the response from the Pi:
image.png

Now go ahead and reboot the Pi, and open a webrowser on the Pi and goto "localhost:1880" or if on another machine "your-pi-address:1880". 1880 is the port that Node-Red listens to, and you should see a blank pallette:
image.png

However, we're missing the dashboard nodes that will allow us to develop a webpage that can control the GPIO pins on the Pi, so we need to install that as well. So you want to open a terminal and change the directory from your home directory to the node-red: "cd ./.node-red" Notice the period at the beginning of the directory name indicating that it is a hidden directory. You want to run the following command to install the dashboard "npm install node-red-dashboard":
image.png

You can restart the Node-Red service by running "node-red-restart". This allows it to reload the configuration file and they you'll be able to access the dashboard. To program the Pi using Node-Red you point your browser to "localhost:1880" and to view the dashboard you point your browser to "localhost:1880/ui". Since we haven't setup a flow yet, this is what you should see on your dashboard page:
image.png

The install is complete and now we're ready to build the program that will enable us to press a button on a webpage and have it energize a GPIO pin on the Pi. I'll cover that in the next post.
Thanks for viewing!
Robin

Posted with STEMGeeks



0
0
0.000
15 comments
avatar

Congratulations @robingreig! You have completed the following achievement on the Hive blockchain and have been rewarded with new badge(s) :

You distributed more than 50 upvotes. Your next target is to reach 100 upvotes.

You can view your badges on your board and compare yourself to others in the Ranking
If you no longer want to receive notifications, reply to this comment with the word STOP

Do not miss the last post from @hivebuzz:

Feedback from the January 1st Hive Power Up Day
Happy New Year - Project Activity Update
0
0
0.000
avatar

Is node-red just nodejs for the pi?

0
0
0.000
avatar

Great question! It's built on node.js but it also has the flow editor that allows you to build the software by joining the pieces of the flow. In their words "Node-Red provides a browser based flow editor that makes it easy to wire together flows using the wide range of nodes in the pallette". Plus the hundreds of other nodes that folks all over the world have built and shared in that community!

0
0
0.000
avatar

Ah that’s pretty interesting. I have always been able to install node on my pi the same way as I do on my other servers so I was wondering why you chose to install that.

0
0
0.000
avatar

In my opinion, Node-Red is a GUI for node.js. It allows you to easily generate complex programs with a simple to use and understand User Interface. I don't know node.js and when I look at the code I've generated from my flows, I really have to sloooowly go thru the lines to try to understand what it taking place.

0
0
0.000
avatar

If I ever log into the GUI on my pi(its logged into CLI because of power reasons and I don't want to have to reload all the programs running on it) I'll give it a try. Thanks for explaining it to me.

0
0
0.000
avatar

Ah this is cool. I need to buy me one of these Pi devices! I heard they are really good and helpful to do and learn coding with it.

0
0
0.000
avatar

Yep! Best value in my opinion is the Raspberry Pi 4 with 2GB of RAM. For your first, I would suggest purchasing a kit that has the USB-C power supply, and the regular HDMI > Micro HDMI cables to allow you to plug it in to a regular monitor. They often supply a pre-programmed card that will allow you to be up and running quickly. Another bonus of the Pi is that if you really mess up the software, you simply plug the SD card into your computer and download a new image (very easy)! Also a great way for you to practice your new python skills!!!

0
0
0.000
avatar

It's definitely worth getting one. I've got one on my desk and I SSH its being used daily. I mostly run some hive(and other non hive) related scripts on that which I don't care enough about to purchase a dedicated VM for them. They are really cheap(I paid about $100 for a kit with everything I needed to get started with the 8 GB Pi 4) and you can do so much with them.

0
0
0.000
avatar

You have a typo, you show 1800 instead of 1880 after first reboot.

0
0
0.000
avatar

Thanks for catching that! That's what happens when you post first thing in the morning before the third cup of coffee!!!

0
0
0.000
avatar

Well you can edit it....

I got it installed and running. Looking forward to next post.

0
0
0.000
avatar

No pressure for tomorrow morning then.....(grin)! If you ever want a sample of one of my flows, they are easy to download and the upload into another Node-Red machine. I use this process to backup my flows and I recently changed out my mqtt mosquitto broker from a Pi 3 to Pi 2 because I only use a wired connection for my broker for higher reliability and didn't want to waste the Pi3 when the Pi2 is more than enough. So I downloaded the flow from the Pi3 and uploaded it into the Pi2, very slick!

0
0
0.000
avatar

That would be great. I found the tracer SD card I will look into making an ISO from it and we can figure out how to get it to you. I will see if I can upload it to my github.

0
0
0.000
avatar

Great idea! I'll swap you the ISO on your github for my flows on mine (grin)

0
0
0.000