Introduction: Node-RED Application Development With Sensorian
Node-RED is a node.js based tool for developing Internet of Things (IoT) applications by wiring together various types of nodes. These nodes enable an application to read sensors, control outputs, read and write data to Web APIs, and process events. We have developed our Sensorian shield to integrate with Node-RED. A set of nodes gives a Node-RED developer the ability to interact with Sensorian's inputs and outputs.
Step 1: Setting Up Your Raspberry Pi
The Raspberry Pi's operating system must be configured to communicate
with the Sensorian shield. The simplest way to do this is to use our image created specifically for using Sensorian on Raspberry Pi. Download an image from http://sensorian.io/downloads/ and burn it to an SD card or alternatively, build your own with our build script.
Step 2: Beginning Node-RED Development
Open a terminal and type:
Press Enter, then type:
Open another terminal and type:
Wait until the Server now running message appears then open the Web browser on the Raspberry Pi (slow) and visit 127.0.0.1:1880 or the Web browser on your PC (faster) and visit IP-ADDDRES-OF-RPI:1880.
Step 3: Displaying Live Transit Information
www.nextbus.com provides a public XML data feed, for many different cities, containing information about how public transit buses are keeping on schedule. Detailed documentation for their API can be found here. In this example we will be monitoring TTC Bus 12 at the Victoria Park Subway station in Toronto, Ontario, Canada. The data URL for this station is
but if you are interested in data at another location visit
and make note of the agency tag. Then visit
replacing AGENCYTAG with the agency tag from the previous step. Now make note of your selected route tag. Now visit
replacing AGENCYTAG and ROUTETAG with the agency and route tags from the previous steps. Make note of your selected stopId.
Your data URL will be
replacing AGENCYTAG, ROUTETAG, and STOPID with the previously obtained agency tag, route tag, and stopId respectively.
Step 4: Configuring the Touchpad Switch
This application will be designed so that pressing Sensorian B1 will display information about the first bus serving the stop and pressing Sensorian B2 will display information about the second bus serving the stop. To start, first drag the touchpad node into the workspace and then drag a switch node. Double-click the switch node and set its Name to Touchpad Switch. Add a == 1 rule and a == 2 rule. Then wire sensorian-touchpad to the left side of Touchpad Switch.
Step 5: Using Nextbus API
Drag two http request nodes into the workspace. Set the URL for both of them to the URL obtained in Step 3. In this example it will be
Leave everything else as is. Wire the left side of both http request nodes into the outputs of the Touchpad Switch node.
Step 6: Parsing Data
Drag two function nodes into the workspace. Double-click the first one and name it BUS1. Name the second one BUS2. Set the function of BUS1 to the code at
Set the function of BUS2 to the code at:
Step 7: Displaying Data
Finally, the data must be displayed. Drag a Sensorian tft node into the workspace and wire it to the right sides of both BUS1 and BUS2. Double click sensorian-tft and set its Orientation to Landscape.
Step 8: Using the Program
Deploy the program. Press B1 on the Sensorian to display the first bus schedule and B2 to display the second bus schedule.
Step 9: About Sensorian
To learn more about the Sensorian shield please visit, http://www.sensorian.io