2. Hello!
I am Dr. Dom Guinard
Co-invented the WoT, Co-Founded
EVRYTHNG & loves: Web technologies,
standards, startups, books and mountains!
@domguinard
2
3. If I tell you...
✗ NPM
✗ GPIOs
✗ PIR
✗ LPWAN
✗ MQTT
✗ WoT
✗ REST
✗ Websockets
✗ NodeRED
✗ IFTTT
✗ Ethereum
✗ Tensorflow
3
4. What’s in the course?
The IoT, the WoT
History, applications, ...
Getting started with
embedded devices
Sensors, actuators, devices, GPIOs,
...
The I in IoT
Networking layers and protocols,
Zigbee, Bluetooth, LPWAN, WiFi,
etc.
4
The W in IoT:
Web of Things!
Architecture, layers, API for Things
Layers of the WoT
Access, Find, Share, Compose
The Future of the IoT
From blockchain to AI and other
buzzwords & challenges ahead for
the IoT
5. The Web of Things Book!
Course largely based on the book
Books and kits options on:
http://book.webofthings.io
Use 39guinard
To get 39% discount on Manning
5
7. “[...] the phrase "Internet of Things"
started life as the title of a
presentation I made at Procter &
Gamble (P&G) in 1999. Linking the
new idea of RFID in P&G's supply
chain to the then-red-hot topic of
the Internet [...]”
[@Kevin_Ashton]
7
14. Lab: Setting up your Pi!
14
See also: Chapter 4, page 94
1. Install Etcher from https://etcher.io
2. Install your Pi:
https://webofthings.org/wot-book-pi-image/
20. Lab 1: A Webserver on a Pi!
20
See also: Chapter 3 & Chapter 4, page 94
1. Connect your Pi to the network
a. ping raspberrypi.local and write
down your IP
2. Build your (first?) Node HTTP server on the Pi (page
64)
3. Bonus: Install NVM & Node.js on your computer
a. curl -o-
https://raw.githubusercontent.com/creationix/nvm
/v0.33.2/install.sh | bash
b. nvm install v4.9.1
4. Bonus: build a more advanced server, see Listing
3.2 page 66
21. Lab Notes: Headless setup
21
✗ Change MDNS hostname of your Pi:
✗ sudo nano /etc/hostname
✗ Headless SSH:
✗ Add: /boot/ssh
✗ Headless config of the wifi:
✗ Add: /boot/wpa_supplicant.conf
22. Some key points so far...
✗ IoT came from RFID in 1999
✗ The Things in the IoT typically have 4 properties:
✗ Identity
✗ Connectivity
✗ Sensing
✗ Actuating
✗ There are 2 world of embedded devices:
✗ Linux Devices (ARM, e.g., Pi)
✗ Microcontrollers (e.g., Marvell, TI)
✗ Javascript (Node) is taking over things for prototyping
22
27. 27
var Gpio = require('onoff').Gpio,
sensor = new Gpio(17, 'in', 'both'); //#A
sensor.watch(function (err, value) { //#B
if (err) exit(err);
console.log(value ? 'there is someone!' : 'not anymore!');
});
function exit(err) {
if (err) console.log('An error occurred: ' + err);
sensor.unexport();
console.log('Bye, bye!')
process.exit();
}
process.on('SIGINT', exit);
// #A Initialize pin 17 in input mode, 'both' means we want to handle both rising and falling interrupt edges
// #B Listen for state changes on pin 17, if a change is detected the anonymous callback function will be called with the
new value
29. Lab 2: GPIOs
29
See also: Chapter 4, from page 102
1. Setup the PIR sensor (see page 104)
2. Connect it to onoff.js code (see
chapter4-gpios/pir.js)
3. Bonus: setup the DHT sensor (see Chapter 4 from
page 105)
31. Categories of protocols
PAN: Personal Area Net
WiFi, Zigbee, Enocean,
Thread, Bluetooth, etc.
Usually for consumer IoT:
Smart homes, smart
buildings, beacons, etc.
(LP)WAN: Low Power
Wide Area Net
SigFox, LoRA, 5G, NB-IoT,
CAT-M, etc.
Usually for industrial &
commercial IoT:
Smart cities, supply chain
tracking, smart meters,
etc.
31
32. 32
Good reasons for no IP+Web end-to-end
Battery Powered Devices Deployment requires a mesh
35. The emergence of LPWANs
✗ New networks created for the IoT
✗ Smart meters, Supply chain
tracking
✗ LP = Low Power
✗ 3 big categories:
✗ SigFox (the first)
✗ LoRA (the more “open” - see
TheThingsNetwork)
✗ 5G IoT (the “operators”)
✗ CAT-M
✗ NB-IoT
35
36. Demo: LPWAN & TTN
36
✗ Using a TTN Node
✗ Communicating with EVRYTHNG
37. Some key points so far...
✗ Sensors and Actuators are integrated to IoT
prototypes (and products) via GPIOs
✗ There are a lot of networking technologies involved in
the IoT. In particular because of the energy
consumption of WiFi and need for mesh.
✗ Very low-power protocols are emerging (LPWAN)
37
51. 51
$(document).ready( //#A
function doPoll() {
$.getJSON('http://devices.webofthings.io/pi/sensors/temperature', //#B
function (data) { //#C
console.log(data);
$('#temp').html(data.value + ' ' + data.unit); //#D
setTimeout(doPoll, 5000); //#E
});
});
//#A Wait until the page is loaded and then call doPoll()
//#B Use the AJAX helper to get the JSON payload from the temperature sensor
//#C When the response arrives, this function is called
//#D Select the "temp" HTML element and update its content using the data.value (the value) and data.unit
(the unit) returned in the JSON payload
//#E The doPoll() function sets a timer to call itself again in 5 seconds (5000 milliseconds)
52. Lab 3: Talking Web to a Thing!
52
✗ Fork & Clone the book code on your machine
✗ git clone https://github.com/webofthings/wot-book
--recursive
✗ Browse the device as a Human on:
http://devices.webofthings.io/
✗ Install Postman and browse the device as an App
✗ URL: http://devices.webofthings.io/
✗ Accept: application/json
✗ Modify 2.2 code to get the humidity value every 5
seconds
✗ Bonus: change the type of graph in 2.2
53. Web API for Things: 5 Steps
A. Resource design—Identify the functionality or services
of a Thing, and organize the hierarchy of these services.
B. Representation design—Decide which representations
will be served for each resource.
C. Interface design—Decide which commands are possible for
each service, along with which error codes.
D. Resource linking design—Decide how the different
resources are linked to each other.
E. Integration strategy—Choose a pattern to integrate
Things to the internet and the web.
53
58. 58
function subscribeToWs(url, msg) {
var socket = new WebSocket(url);
socket.onmessage = function (event) {
console.log(event.data);
};
socket.onerror = function (error) {
console.log('An error occurred while trying to connect to a Websocket!');
console.log(error);
};
socket.onopen = function (event) {
if (msg) {
socket.send(msg);
}
};
}
//subscribeToWs('ws://localhost:8484/pi/sensors/pir);
60. Lab 4: Designing the Pi API
60
✗ See also: Chapter 7
✗ Code deep-dive together
✗ chapter7-implementation/part1-2-direct-gateway
✗ Resources (add a noise sensor)
✗ Representation (see messagepack)
✗ Adding a representation
✗ Add CBOR support
✗ npm install --save cbor
✗ In converter.js
✗ Bind PIR sensor on your Pi
✗ Communication via WebSocket
✗ chapter2-hello-wot/client/pir-websockets.html
✗ Bonus: bind the DHT sensor of your Pi (see page 183)
67. Lab 5: Gateways
67
✗ See also: Chapter 7, page 195
✗ CoAP
✗ Start the CoAP server
✗ Look into the plugin
✗ Request a CoAP resource via HTTP:
✗ /things/coapDevice/sensors/co2
✗ EVRYTHNG Demo
✗ Bonus: connect your PIR sensor to EVRYTHNG
71. 3 Challenges in IoT Findability
What’s the Bootstrap
URL?
mDNS
What’s the format I should
expect (syntax)?
REST, JSON, WoT Model
What does that mean
(semantics)?
W3C WoT, Schema.org
IoT
71
72. How to find the URL of a Thing? mDNS!
service up: {
interfaceIndex: 4,
type:
{ name: 'http',
protocol: 'tcp',
subtypes: [],
fullyQualified: true },
replyDomain: 'local.',
flags: 3,
name: 'Brother MFC-8520DN',
networkInterface: 'en0',
fullname:
'Brother032MFC-8520DN._http._tc
p.local.',
host: 'EVT-BW-BROTHER.local', The
service
port: 80, local IP address
addresses: [ '192.168.0.6' ]
}
72
✗ mDNS clients listen for mDNS
messages (on UDP)
✗ DNS tables are populated from
what they catch
✗ Your Pi broadcasts mDNS
messages as we speak!
76. The WoT Model Continues @ W3C
{
"@context": ["http://www.w3.org/ns/td",
{"iot": "http://iotschema.org/"}],
"@type" : "Thing",
"id": "urn:dev:wot:com:example:servient:lamp",
...
"security": [{"scheme": "psk"}],
"properties": {
"status": {
"@type" : "iot:SwitchStatus",
"description" : "Shows the current status of the
lamp",
"writable": false,
"observable": false,
…
"actions": {
"toggle": {
"@type" : "iot:SwitchStatus",
"description" : "Turn on or off the lamp",
"forms": [{
"href": "coaps://mylamp.example.com/toggle",
"mediaType": "application/json"
76
✗ Model:
✗ Things
✗ Properties
✗ Actions
✗ Events
✗ Extensible via
SemanticWeb
✗ https://schema.org
https://w3c.github.io/wot-thing-description/
77. Lab 6: Semantic Web of Things
77
✗ See also: Chapter 8
✗ Experiment with the Web Thing Model in Action:
Automatic UI generation, use
✗ Use the wot.js server in chapter8-semantics
✗ http://IP:8484/model
✗ Test the client:
chapter10-mashups/UI/UI.html
✗ Bonus:
✗ Bind an LED on your Pi to react to Actions
✗ Play Mozilla Things Project, a modern
implementation of the Web Thing Model
80. Basic Principles of IoT Security
Over the air
updates
TLS
Communication
Device
Authentication
80
81. Securing Things (over simplified!)
81
✗ Problem 1:
✗ TLS Web Encryption
✗ Problem 2:
✗ SSL (TLS) certificates
✗ Problem 3:
✗ API keys (oAuth)
✗ TLS certificates on device
83. Lab 7: Secure & Share Things
83
✗ See also: Chapter 9
✗ Securing our server
✗ Encryption:
✗ openssl req -sha256 -newkey rsa:4096
-keyout privateKey.pem -out caCert.pem
-days 1095 -x509
✗ Try: https://localhost:8484/pi/
✗ Secure proxy with Ngrok:
✗ Put your Pi on the Web with Ngrok
✗ wget
https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stabl
e-linux-arm.zip
✗ ./ngrok http 8484
✗ Bonus:
✗ Test the social WoT proxy (from page 260)
88. Lab 8: Composing Things
88
✗ See also: Chapter 10
✗ Create an IFTTT mashup that
✗ Sends a turn LED on Action to your WoT Pi
✗ Connect our PIR sensor to Node-RED (see page 293)
✗ Launch the unsecure version (chapter 8)
✗ Node-red
✗ Connect to:
ws://IP:8484/properties/pir
✗ Bonus:
✗ Implement the full Node-RED mashup (see page
292)
✗ Try the full JS mashup of chapter 2:
ex-5-mashup.html
89. Links
✗ Web of Things Community
✗ WoT @ W3C and WoT W3C Architecture
✗ Mozilla WoT
89
91. IoT’s challenges & the Future!
1. Interoperability
✗ The (semantic) Web can help!
2. Scalability
✗ Decentralization will be key (blockchain)
✗ Dealing with the data overload (machine learning)
3. Privacy
✗ GDPR, Data marketplace
4. Security
✗ Use Web security, prepare for Quantum computing!
5. Durability
✗ Regulation, IoT Mark
6. Usability
✗ The disappearing computer
91
92. Key takeaways
✗ The IoT is here and now, 20 billion connected objects
expected to join by 2022, enormous opportunity
but significant challenges
✗ Networks are evolving to support the special needs
of Things
✗ Interoperability is key, the Web can help at many levels
92
93. 93
Thanks!
You can find me at:
✗ @domguinard
✗ dom@guinard.org
✗ http://dom.guinard.org
✗ https://webofthings.org
94. SlidesCarnival icons are editable shapes.
This means that you can:
● Resize them without losing quality.
● Change fill color and opacity.
Isn’t that nice? :)
Examples:
94