Raspberry Pi 2 Node-Red setup

In order to setup node-red, node.js is required.  Node.js runs on javascript and is one of the building blocks of node-red.  The install processes for Raspberry Pi and Raspberry Pi 2 are different and have different instructions.  Below are instructions for Raspberry Pi 2 and I have tested this process on Raspian wheezy 2015-20-16.  These are my own notes for my own purposes, but hopefully somebody else will find them useful too.

Before running these, update Raspian first.

Installation

To install node-red for the Raspberry Pi 2, the node-red guys have made it much easier.

Run the following command. This will update the raspian package cache and the source list.

Now to install all the packages.

Verify that node and npm have installed correctly. Run the following.

You should get results similar to the following.

Once these are installed, run the following command to install node-red.

This takes quite some time.

I got a few warnings and the build of the node-icu-charset-detector node failed completely, however node-red still built successfully.

Now to test node-red. Run the following to start node-red from the command line.

Node-Red should start and should look something like this.

You should get the node-red web interface by going to the following page in your web browser.

Now to install an initialisation script so that node-red can run as a service and start/stop automatically on startup/shutdown.  Create a new init.d file by running the following.

Then copy and paste the script below into this file and save.  This script will run node-red as the user pi.  It’s very simliiar to the Adafruit (link below) except updated for the new installs for Raspberry Pi 2.

Once the init script has been saved, it needs to be made executable and added to rc.d so it will start and stop at startup and shutdown.

You can also start/stop/restart the node-red service using this script.

node-red addons

There are many addons for node-red.  Some of my favorites are ping, wol, emoncms, prowl, mysql and pushbullet – but there is many others. To install them, use npm from the node-red directory.  The following will install my favorite addons.

There are many other addons and you can find other packages at https://www.npmjs.com/

Troubleshooting

I found that the install didn’t always successfully compile all addons. If there is an addon you expect to see in the node-red GUI that is not there, you can enable more verbose logging.  It should tell you if it is getting any errors or if it cannot load a specific module.  The below will run node-red manually from the command line.  Ctrl-C to break out.

Useful node-red sites & references

https://learn.adafruit.com/raspberry-pi-hosting-node-red/setting-up-node-dot-js
Adafruit has a very nice guide for setting up node-red on a Raspberry Pi (version1). Very useful.

https://www.npmjs.com/
Has many npm packages which can be installed.

http://nodered.org/
The Node-Red site.

https://www.youtube.com/watch?v=f5o4tIz2Zzc
Interesting demo. Twitter, Mongo REST API and sentiment Analytics in 3 minute demo.

https://github.com/node-red/node-red
The Git Hub repository for Node-Red.