No coding required: Node-RED on a Raspberry Pi

Check out this tutorial to see how easy it is to set up hardware flows with Node-RED's drag-and-drop interface.
523 readers like this.
Best of Opensource.com: Hardware

Thomas Hawk on Flickr. CC BY-NC 2.0. Modified by Opensource.com

Node-RED is a programming tool that lets you quickly connect hardware devices using a browser-based editor. It comes with a wide range of nodes that can be used to build flows in a drag-and-drop manner, significantly reducing your development time. Node-RED is installed with Raspian Jessie for Raspberry Pi, and there is also an option to download Node-RED separately.

To show you how it works, we'll build a simple tool using Node-RED to communicate with a cellular modem connected to a Raspberry Pi. With cellular modems, you can send/receive data from your Raspberry Pi over a cellular network. You can use one of the 3G/4G USB dongles commonly available through cellular network providers, or you can connect a development board with a 3G or 4G wireless modem.

Whether you're connecting with a USB dongle or a development board, the connection interface to the Raspberry Pi is through a USB port. In this tutorial, I'm connecting a SIM900 development board to Raspberry Pi through a USB-to-serial converter cable.

Connecting SIM900 to Raspberry Pi through a USB-to-serial converter cable

opensource.com

The first step is to check that the SIM900 development board is connected to the Raspberry Pi.

Checking that the SIM900 development board is connected

opensource.com

The USB-to-serial adapter shows up here as one of the USB devices connected to the Raspberry Pi.

Next, check the USB port number the SIM900 board is connected to.

Checking the SIM900 board's USB port number

opensource.com

In the last line above, you can see that the SIM900 board (connected through the USB-to-serial converter) is connected to ttyUSB0 on the Raspberry Pi. Now we're ready to start using Node-RED.

Launch Node-RED on the Raspberry Pi.

​​​​Launching Node-RED in Raspberry Pi

opensource.com

Download this sample flow and import it into Node-RED. Note that the flow file is a JSON representation of the graphical UI.

The imported flow should look like this in Node-RED:

The imported flow in Node-RED

opensource.com

Injection nodes set up AT commands required to query the modem. The Add Newline function node appends \r\n to the AT commands passed from the injection nodes. Output from Add Newline is then wired to the Serial Out node, which writes data to the serial port. The AT command response from the modem is read through the Serial In node, which outputs the response to the Debug window. Make sure the serial port number and port speed are configured in both the Serial In and Serial Out nodes.

Node-RED is an easy-to-use programming tool that can be used to quickly integrate and test hardware devices. As you can see from this tutorial, connecting and testing a cellular mode with Raspberry Pi using Node-RED required no coding at all.

For more information about Node-RED and other ways it can be used, visit the project's website.

User profile image.
My interest is in software development for IOT projects especially those that uses cellular modems.

Comments are closed.

Creative Commons LicenseThis work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License.