One of the many things that Raspberry Pi-based systems are excellent for is for building Internet of Things platforms. The price is right ($35), the performance is great for the price, the input/output options are great, there’s an enormous ecosystem of add-on and compatible sensors and other hardware, and an equally enormous supporting community.
As a result of this vibrant market, a slew of operating system choices for the Raspberry Pi have appeared (see my Ultimate Guide to Raspberry Pi Operating Systems parts 1, 2, and 3) along with some really creative software development tools such as Node-RED, a free, open source, visual wiring tool built by IBM Emerging Technologies.
Node-RED was first released for x86 platforms in 2013 and the Raspberry Pi version now comes pre-installed in the Raspbian “Jessie” release of Debian officially released last December by the Raspberry Pi Foundation (although other companies such as Adafruit had Node-RED working on the Raspberry Pi almost a year earlier). And not only does Node-RED run on Windows, Linux, and OS X, it also runs on the Beaglebone Black single board computer and there’s support for connecting Node-RED to Arduino boards.
What’s remarkable about Node.js is how quickly it’s grown in popularity and power though not everyone might agree on its general usefulness (NSFW).
Sorry, gotta do it; here’s “Hello World” for Node.js:
In the following "hello world" example, many connections can be handled concurrently. Upon each connection the callback is fired, but if there is no work to be done Node is sleeping.
Node.js now has well over 225,000 available packages and its own package manager called, boringly, “npm” which is included when Node.js is installed. I mention this because you’ll need some npm “fu” if you’re going to extend Node-RED using the npm repositories.
Node-RED provides a set of building blocks, or “nodes,” which you drag from the left hand palette onto the canvas. You then drag a connection from an output connector on the right side of a node (for those that have outputs; some, such as the debug node which just displays input data, do not), to the input connectors on the left side of a node (again, for those nodes that take inputs). You then edit the properties of each node as needed, click on Deploy, and your process, called a “flow,” starts running with messages being sent a received by nodes.
In the default Node-RED installation there’s large number of nodes types preinstalled including searching for tweets, analyzing text for sentiment, running commands, sending and receiving HTTP requests, queuing and dequeuing message, sending and receiving UDP and TCP requests, and processing CSV, HTML, JSON, and XML messages.
Need more functionality? Nodes are available to support services such as accessing MongoDB and MySQL, interacting with IRC, and using Mustache templates by adding them from npm repositories. This can be done locally from the command line using either npm or the node-red-admin tool (this can also be used remotely).
Pre-built flows are also available from the Node-RED Library which also indexes available nodes. To use a flow, you copy its JSON from the library, then paste it into the Node-RED user interface. You can also save and retrieve flows into your local library.
Node-RED also provides admin, runtime, and storage APIs although you’ll find the documentation pretty scant at present.
If you’re not got a preinstalled Node-RED system then, in theory, installation should be simple. First, if needed, install Node.js:
Check the version and if you get this message:
user@xxx:~ $ node --version
*The program 'node' can be found in the following packages:
Ask your administrator to install one of them*
You need to do this:
sudo ln -s /usr/bin/nodejs /usr/bin/node
And node should work fine (though no guarantees). Now you can install Node-RED using npm.
As well as running Node-RED on a Raspberry Pi 2B, I’ve explored Node-RED using Ubuntu 14.04 installed in a VirtualBox VM on OS X, directly installed on OS X, in a Docker container running on a QNAP NAS and in all installations it’s been solid. As a tool for building IoT applications Node-RED is definitely worthing evaluating. It’s robust, flexible, and definitely addictive (you’ll find yourself thinking “can I just do X with Node-RED?” and then another hour or two will vanish).
If you think this review contains lots of cool RPi stuff, you might also like:
- Ultimate Guide to Raspberry Pi Operating Systems Part 1
- Ultimate Guide to Raspberry Pi Operating Systems Part 2
- Ultimate Guide to Raspberry Pi Operating Systems Part 3
- Sonic Pi: Realtime music creation for the Raspberry Pi (and more)
- New Raspberry Pi 3 Model B Launched
- 10 Reasons why the Raspberry Pi 2 Model B is a killer product
- MIPS Creator CI20: Sort of a challenge to the Raspberry Pi 2 Model B
- Ten operating systems for the Raspberry Pi
“Wake up!” the good folks a Merriam-Webster just tweeted. “Sheeple is in the dictionary now.”
Wireless LAN users can’t just stay comfortable in the 5GHz realm – the older 2.4GHz frequency bands are...
A review of 18 companies that offer free cloud storage
The legal fight between Apple and Qualcomm on licensing modem technology is turning uglier every day.
F5’s new President and CEO, Francois Locoh-Donou talks about his vision for the app delivery...
Companies of all sizes and types are rethinking not only how their employees work, but also where that...
Use cases in industries such as aeronautics and chemicals are a proving ground, and a roadmap to...