Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Web of Things (wiring web objects with Node-RED)
1. Web of Things
(wiring web objects with Node-RED)
Francesco Collovà - francesco.collova @ gmail.com
about.me - http://about.me/francesco.collova
LinkedIn - it.linkedin.com/in/fcollova/
20/03/2015
2. Web of Things
The Web of Things (WoT) is a term used to describe approaches, software
architectural styles and programming patterns that allow real-world objects to
be part of the World Wide Web.
WoT reuses existing and well-known Web standards (e.g., REST, HTTP,
JSON), semantic Web (e.g., JSON-LD, Microdata, etc.), the real-time Web
(e.g.,Websockets) and the social Web (e.g., oauth or social networks).
While there are ongoing efforts to standardise it,the WoT is a set of best
practices that can be classified according to the Web of Things architecture.
http://en.wikipedia.org/wiki/Web_of_Things
3. WoT Requirements
Common WoT scenarios require integration with online web services
and (near) real time sensors and actuators to allow monitoring and
interaction, and computing:
● Device Sensors can interpret raw sensor readings to send
“presence & info” events;
● Device Actuators can interact with the environment to
accomplish a specific action;
● Gateways can aggregate data from several sensors and
perform some simple data processing;
● Server cloud-based systems can connect to online services and
web service (real time access to social network feeds and alert
channels)
● SmartPhone App & People (Robots & Drones)
WoT require the coordination of computing resources hosted on “things” and “servers”
across the Internet (hosted in the cloud, on gateways and on “smart devices”)
4. Data Flow Paradigm for WoT
Data Flow Programming is a paradigm in which computation is modelled as a directed graph (which
may or may not contain cycles), the nodes of which are either data sources (producers of data), data
sinks (consumers), or "processing elements" which compute some function; and the arcs of which
represent data flow between nodes.
When asynchronous nodes operate whenever there is data at their input vertices (the push model) or
requests for data upon their outputs (the pull model).
Several platforms provide a data flow programming paradigm where computer programs are modeled
as “directed graphs” connecting networks of “black box” nodes that exchange data along connected
arcs.
Provide more flexibility and maintaining ease of use.
5. Cloud Service
Presence Sensor
SmartPhone
Server
Data Flow Program Example
User Phone
Text analysis
Trending
Topics
Habit
Analysis
Likes
User Sensor
Smart TV
Presence
Monitor
Info Receiver
Analysis
TV Controller
Program
Schedule
Twitter Input
Data Flow
Messages
6. Technologies
● Python, Javascript & Json
● Node.js web ecosystem
● NoSQL high throughput
database
● Cloud Computing (container
& deploy)
● low cost HW ecosystems:
o Arduino
o RaspberryPI
7. High scalable & data web/mobile app
Modern web app needs to handle ten thousands of
concurrent connections and require low latency (C10k
problem http://en.wikipedia.org/wiki/C10k_problem ).
Issues:
● Avoid deadlock situations
● Manage Race-Conditions (sequence or timing
uncontrollable events)
● Heavy Context Switching headaches
● Big memory consumptions issues.
8. Node.js
NODE.js IS A PLATFORM BUILT ON CHROME'S JAVASCRIPT RUNTIME FOR EASILY BUILDING
FAST, SCALABLE NETWORK APPLICATIONS. NODE.JS USES AN EVENT-DRIVEN, NON-
BLOCKING I/O MODEL THAT MAKES IT LIGHTWEIGHT AND EFFICIENT, PERFECT FOR DATA-
INTENSIVE REAL-TIME APPLICATIONS THAT RUN ACROSS DISTRIBUTED DEVICES.
image taken from http://kunkle.org/nodejs-explained-pres/#/conceptually-simple
Image taken from http://www.aaronstannard.com/post/2011/12/14/Intro-to-NodeJS-for-NET-
Developers.aspx
9. Node-RED
A visual tool for wiring the Internet of Things.
● Open Source Apache V2.0
● Node-RED is created by IBM's
Emerging Technology
(http://nodered.org)
● Based on Node.js ecosystem
● Rapid Prototyping for IoT
● Node-Red provide a browser
based flow editor to wire the wide
typology “node” available
10. Node-RED
● Message are Json objects
● Different categories of “nodes”
o input to process incoming message: trigger, TCP, UDP, websocket,
MQTT, file, datastore, social, custom nodes;
o output to send outgoing message: debug, HTTP, TCP, UDP,
websocket, MQTT, file, datastore, custom nodes
o function to manipulate message: trasform, filter, map, analyse
o function node: run javascript code in a sandbox
f
msg
msg2
msg1
javascript