Internet of Things developers need a tool to wire things together, and they also need to know how to maximize usage of existing services to create powerful connected apps. This session explains the usage of Node-RED as a tool to build powerful integrations that help in creating the connected products. We will explore integrations with devices and also with services to enable smarter products.
2. Agenda
Brief introduction to the IoT and IBM Internet of Things Foundation
What is Node-RED?
Node-RED and the IOT
In a Device or Gateway
In Bluemix
Demonstration
Patterns of Use
3. Building the Internet of Things with IBM
Secure
intelligence and action is
critical from the thing up
through
industry solutions
Analyze & Optimize
information from across the
lifecycle, leveraging insight
for action
Connect, Collect and Store
information from a range of
things with range of volume,
variety and velocity
Operate
infrastructure safely and
securely from rollout to
production
Manage
the lifecycle of things
ensuring safe, reliable and
predictive operations
Industry-specific Solutions
Design &
Engineer Operate Manage
Analyze and Optimize
Connect, Collect and Store
SecureProducts,
Assets,
Infrastructure
Protocols & Gateways
Design and Engineer
things and applications,
addressing requirements
management and complex
system design processes
4. Industry-specific Solutions
Design &
Engineer Operate Manage
Analyze and Optimize
IBM Internet of Things Foundation: What is it?
Products,
Assets,
Infrastructure
Protocols & Gateways
Secure
Connect, Collect and Store
A new offering within IBM’s Bluemix PaaS offering that allows Internet-
connected devices to be integrated directly into Bluemix solutions
Connect, Collect and Store
information from a range of
things with range of volume,
variety and velocity
5. Internet of Things Infrastructure
In most IoT applications the predominant flow of data is between device to backend
In some applications there is communication between the devices themselves
Physical World
Wide Area Network
IoT
Gateways
Physical World
Sensor Network
IoT Service Platform
Smart
supply chain
Smart
grid
Smart
healthcare
Smart
building
app1 app2 app3
Cloud Provider
or Data Center
Home gateways, Mobile
Phones etc.
Back end Applications
and analytics. May have
mobile / web interfaces
Devices in the field. May
connect through
gateways (as shown) or
have direct connection to
the backend
Connect, Collect
and Store
6. Building an IoT Solution
5
Connect, Collect, Store
Mobile Push
Sensors
Historian service
NoSQL, Relational,
Timeseries & Spatial
storage & analytics
Custom Application
Bluemix /
Softlayer
BigInsights
Cloud infrastructure
Hadoop
Publish /
Subscribe
MQTT protocol
Assemble
Wire
MQTT server
MQTT client
8. Why did we develop Node-RED?
• Internet of Things solutions often require us to pull together
different device APIs and online services in new and interesting
ways.
• Time spent figuring out how to access a Serial port, or to
complete an OAuth flow against Twitter is time not spent on
creating the real value of a solution.
• We need tools that make it easier for developers at all levels to
bring together the different streams of events, both physical and
digital, that make up the Internet of Things.
9. It provides a browser-based UI for creating flows of events and deploying them to
the runtime.
Its light-weight runtime, built in node.js, is
ideal for edge-of-network environments
or running in Bluemix
It can be easily expanded by adding new
nodes to its palette – taking full advantage
of the node package manager (npm)
ecosystem
Node-RED makes it easy to wire together the IoT
10. Released on GitHub September 2013
Apache 2 License
3rd party pull-requests accepted under
Contributor License Agreement
Contributions having included nodes for:
• Twillio (sms capability)
• Postgres
• Amazon Dynamo
• Active Google Group and irc channel
http://nodered.org - main site
http://flows.nodered.org
–Recently launched online flow library
–Encourages sharing and reuse of flows
within the community
Open Source Development
11. Component parts
10
node.js runtime
Node-RED runtime
Node-RED editor (UI)
Flow store
Browser-based editor. Lets
you create flows and deploy
them to the runtime
User-written flow
Nodes
• Standard node-RED nodes
• Third-party contributions
• User-written
Executes a single flow. It is a
node.js application
Event-driven JavaScript
runtime. Runs in Bluemix or
standalone (e.g in a device)
12. Node-RED Flows and Nodes
11
Input node: reads
events from IoTF Debug node: writes
output to debug window
These wires are attached to the same
terminal, so output from “IoT App in” is
copied to both receiving nodes
Switch node: routes incoming
messages to one or more of its
output terminals
Node-RED implements a graphical Data Flow language.
Flows can be imported or exported as JSON objects
13. JSON version of the flow on the previous slide
12
[{"id":"3dee4a0b.a71e36","type":"ibmiot in","inputType":"evt","deviceType":"+","format":"json","name":"IBM IoT
App In","service":"quickstart","x":157,"y":269,"z":"47cda051.8d4c18",
"wires":[["90dd0f60.b08ee8","e344143.da0b3e8"]]},
{"id":"90dd0f60.b08ee8","type":"function","name":"temp","func":"return {payload:msg.payload.d.temp};",
"outputs":1,"x":330.5,"y":315,"z":"47cda051.8d4c18","wires":[["5f9326f8.cc5528"]]},
{"id":"5f9326f8.cc5528","type":"switch","name":"temp thresh","property":"payload",
"rules":[{"t":"lte","v":40,"v2":0},{"t":"gt","v":40,"v2":0}],"checkall":"true","outputs":2,"x":496.5,"y":315,"z":"47cda0
51.8d4c18",
"wires":[["8470617.2a0cba"],["39314ca6.c71afc"]]},{"id":"2fab48da.b0a998","type":"debug","name":"cpu
status","active":true,"complete":"false","x":807.5,"y":312,"z":"47cda051.8d4c18", "wires":[]},
{"id":"e344143.da0b3e8","type":"debug","name":"device
data","active":false,"complete":"false","x":347.5,"y":225,"z":"47cda051.8d4c18","wires":[]},
{"id":"8470617.2a0cba","type":"template","name":"safe","template":"Temperature ({{payload}}) within safe
limits","x":660.5,"y":266,"z":"47cda051.8d4c18","wires":[["2fab48da.b0a998"]]},
{"id":"39314ca6.c71afc","type":"template","name":"danger","template":"Temperature ({{payload}})
critical","x":659.5,"y":360,"z":"47cda051.8d4c18","wires":[["2fab48da.b0a998"]]}]
Used to store or exchange flow definitions. Not intended to be read or written by
humans.
15. The board lights LEDs in response to the sentiment of a Twitter stream.
Node-RED running in a device
16. Bluemix Internet of Things Foundation Boilerplate
• Bluemix IoT Foundation Starter Boilerplate for
getting going quickly
• For use with real devices or simulators
• Node-RED editor and runtime customised with
IoTF nodes in its palette
17. Nodes for IoT Foundation
• Standard MQTT input and output nodes
• Available in the regular Node-RED build
• If you use these, you have to enter clientID, credentials and
Topic strings that match the IoTF conventions
• Bluemix-ready IoTF input and output nodes
• Preloaded in the IoTF boilerplate starter version of Node-RED
– Also available in the Node-RED node repository
• Nodes build the clientID, credentials and Topic strings for you
• Connect as an IoTF application
• Device-side IoTF nodes
• Connect as an IoTF device
16
18. Additional Nodes preloaded in the Boilerplate
• IBM Push
• Node for the Bluemix Push Service
• IBM HDFS
• Write data into the Bluemix HDFS Service
17
19. Using the App Input Node in a Bluemix Application
Access via Bluemix service
Says we want to receive events
Lets us listen only for events from
a given device type
The ID of a specific device (or all
devices registered to the IOTF
organization that match the type)
A device might generate more
than one type of event
It might generate more than one
format of message
The “All” checkbox wildcards the
entry, and can be used either
when you want to subscribe to
more than one value. You can
also use it if there’s only one
match but you don’t want to enter
a value in the corresponding box.
API Key is picked up from the Bluemix environment.
The Node connects using an Application Style Client ID
20. Using the App Output Node in a Bluemix Application
Access via Bluemix service
Says we want to send commands
To a specific device type (id’s
aren’t necessarily unique across
different device types)
To a specific device
A device might accept more than
one type of command
This indicates the format that is
used to encode the command
Default data to include in the
command
The command itself can either be
passed into the Output Node from
nodes earlier on in the flow, or
hardcoded here
22. IoT Node-RED patterns
Bluemix Device
1 Application Assembly and Wiring
2 Event Mediation -
3 Device Adaptor
4 Device Simulator -
5 Status Monitoring -
These patterns suggest some ways in which you can use Node-RED
23. • In this kind of pattern you use Node-RED to build all or part of an application to
process data from devices (Node-RED is being used as a quick way to write
Node.js application)
• The Node-RED flow uses one or more Input Nodes to connect to IoTF. It then
uses these nodes to subscribe to receive events from one or more devices
• Some application logic may be coded in the flow itself, but the flow might also
be composed with other Bluemix services (e.g. IBM Push)
• The application might also want to send commands to devices, using an IoTF
Output Node (for example if it is doing home automation/remote control)
Pattern 1 – Application Assembly in Bluemix
24. • This pattern of Node-RED flow is used to take event data from one or more
devices and then mediate it before forwarding it on to applications. Mediation
could include
• reformatting the event data
• filtering data out of a given event
• filtering out an entire event
• The mediation flow uses one or more Input Nodes to connect to IoTF to read
incoming messages. It uses other Node-RED nodes to mediate them, and then
uses an IoTF Output node to publish them back to IoTF.
• The output node publishes to an IoTF device topic that corresponds to a “virtual”
IoT Foundation Registered Device. IoTF applications read its data in the same
way that they read data from real Devices
• WARNING: Make sure you don’t inadvertently create a Node-RED flow
that publishes messages to the topic that it is listening on.
Pattern 2 – Event Mediation
25. • These flows use Node-RED to adapt a non-MQTT device so that it can connect
into the IoT Foundation as a registered device.
• This pattern is similar to the Event Mediation pattern except that it receives
events directly from the device and not via the IoTF.
• The flow collects data from the real device via an appropriate input node (a
generic protocol node or a device-specific one), uses Node-RED nodes to
manipulate the data from the device and then uses an Output node to publish
the event to IoTF as a device.
Pattern 3 – Device Adaptor
Primary Environment: Gateway
Secondary Environment: Bluemix
26. • In these patterns you use Node-RED to simulate a device which you can then
use to test your backend application.
• It’s similar to the Device adaptor except that it generates its own data. Also it is
more likely to run in Bluemix than in a gateway or device.
• The flow uses Node-RED nodes to generate (or replay) simulated data and then
uses an Output node to publish the event to IoTF as a device.
Pattern 4 – Device Simulator
27. • The IoT Foundation publishes status messages when devices (or applications)
connect or disconnect. In these patterns you use Node-RED to monitor the
availability of your devices (or possibly your apps). This could be to provide
some kind of alert to page someone if a device has gone offline unexpectedly.
• The flow uses one or more Input Nodes to connect to IoTF. It then uses these
nodes to subscribe to receive status events related to one or more devices
• You might also want to monitor status in a Pattern 1 style application. This is so
that an application can send a command to a device if that device is online, but
take some other action (for example call ibmpush) if it is offline.
Pattern 5 – Status Monitor
28. Application or Device?
• The Bluemix IoT nodes always connect as an IOTF Application, not as a
Device. This allows an Output Node to send data purporting to be from any
device in the organization, including unregistered devices.
• This could be advantageous in pattern 2 use cases as it means that
a single mediation flow can mediate data from multiple input
devices, republishing each device’s data on a new topic specific to
that device
• In pattern 3, it allows a device gateway to multiplex several physical
devices onto a single MQTT connection, rather than having to have
a node and MQTT connection for each topic
• Be careful:
• Don’t run the Application nodes in an insecure environment. If you
do and someone manages to extract the API Key from them, then
they have the power to spoof any device in your IoTF organization.
29. Security Considerations
• By default, the Node-RED flow editor created by the IoTF boilerplate does
not authenticate its users. This means that anyone who knows (or guesses)
its URL can open the editor and modify the Node-RED flow – possibly
modifying or redirecting your device data.
• To protect against this you must follow the steps given in the Node=RED
documentation:
• Choose a username and password and generate a hashcode of that password
• Edit the bluemix-settings.js
• Redeploy Node-RED
• NOTE: These steps have changed in Node-RED 0.10
• You should also configure the application to use HTTPS rather than HTTP
• Reminder from the previous slide:
– Don’t run the Application nodes in an insecure environment. If you do and
someone manages to extract the API Key from them, then they have the power to
spoof any device in your IoTF organization.
30. Get started with Node-RED today!
• Build apps in Bluemix
https://www.ng.bluemix.net/docs/#starters/IoT/index.html
• Follow the IBM IOT community on Twitter @IBMIoT
• Visit the Node-RED website
http://nodered.org
• Press articles on Node-RED
–http://gigaom.com/2013/09/27/meet-node-red-an-ibm-project-that-fulfills-the-internet-of-things-missing-link/
–http://www.techrepublic.com/article/node-red/
–http://sdt.bz/content/article.aspx?ArticleID=68755&page=1
–http://www.programmableweb.com/news/node-red-makes-designing-iot-flows-snap/2014/06/09
–http://www.infoq.com/news/2014/05/ibm-node-red-qconlondon
Getting
started
32. Notices and Disclaimers (con’t)
Information concerning non-IBM products was obtained from the suppliers of those products, their published
announcements or other publicly available sources. IBM has not tested those products in connection with this
publication and cannot confirm the accuracy of performance, compatibility or any other claims related to non-IBM
products. Questions on the capabilities of non-IBM products should be addressed to the suppliers of those products.
IBM does not warrant the quality of any third-party products, or the ability of any such third-party products to
interoperate with IBM’s products. IBM EXPRESSLY DISCLAIMS ALL WARRANTIES, EXPRESSED OR IMPLIED,
INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE.
The provision of the information contained herein is not intended to, and does not, grant any right or license under any
IBM patents, copyrights, trademarks or other intellectual property right.
• IBM, the IBM logo, ibm.com, Bluemix, Blueworks Live, CICS, Clearcase, DOORS®, Enterprise Document
Management System™, Global Business Services ®, Global Technology Services ®, Information on Demand,
ILOG, Maximo®, MQIntegrator®, MQSeries®, Netcool®, OMEGAMON, OpenPower, PureAnalytics™,
PureApplication®, pureCluster™, PureCoverage®, PureData®, PureExperience®, PureFlex®, pureQuery®,
pureScale®, PureSystems®, QRadar®, Rational®, Rhapsody®, SoDA, SPSS, StoredIQ, Tivoli®, Trusteer®,
urban{code}®, Watson, WebSphere®, Worklight®, X-Force® and System z® Z/OS, are trademarks of
International Business Machines Corporation, registered in many jurisdictions worldwide. Other product and
service names might be trademarks of IBM or other companies. A current list of IBM trademarks is available on
the Web at "Copyright and trademark information" at: www.ibm.com/legal/copytrade.shtml.
33. Thank You
Your Feedback is
Important!
Access the InterConnect 2015
Conference CONNECT Attendee
Portal to complete your session
surveys from your smartphone,
laptop or conference kiosk.