making things that works with us
DESCRIPTION
In the ”Internet of Things” (IoT) vision the physical world blends with virtual one, while machine-to-machine interaction improve our daily life. Clearly, how these virtual objects are exposed to us is critical, so that their user interface must be designed to support the easiness of usage that is driven by the users’ needs, which is different from what machines requires. These two requirements must be solved, and an integrated solution should emerge, if we want to bring the IoT to the 50 billions network that is predicted to became in the next years. In this talk, you will see how these requirements cannot be met by the same communication protocol, as the user interfaces dictates a way of communication that is no suitable for the "machines". We will analyze what are the state-of-art protocols for both machines and users, and finally we will propose a solution to solve this problem.TRANSCRIPT
![Page 1: Making things that works with us](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bad2874a79596b2b8b464d/html5/thumbnails/1.jpg)
@matteocollinamatteocollina.com
Better Software - Florence 2012/09/26
Making things that work with us!
![Page 2: Making things that works with us](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bad2874a79596b2b8b464d/html5/thumbnails/2.jpg)
Smartphones are changing the world
![Page 3: Making things that works with us](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bad2874a79596b2b8b464d/html5/thumbnails/3.jpg)
How many people will own a smartphone by 2014
1.000.000.000
![Page 4: Making things that works with us](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bad2874a79596b2b8b464d/html5/thumbnails/4.jpg)
Did you see it coming
http://www.flickr.com/photos/12738000@N00/360231193/
![Page 5: Making things that works with us](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bad2874a79596b2b8b464d/html5/thumbnails/5.jpg)
Stevedid.
http://www.flickr.com/photos/noppyfoto/6216399465/
![Page 6: Making things that works with us](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bad2874a79596b2b8b464d/html5/thumbnails/6.jpg)
Thanks.
http://www.flickr.com/photos/noppyfoto/6216399465/
![Page 7: Making things that works with us](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bad2874a79596b2b8b464d/html5/thumbnails/7.jpg)
They didn’t!
...
![Page 8: Making things that works with us](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bad2874a79596b2b8b464d/html5/thumbnails/8.jpg)
What's next(hint: it's a big number)
50.000.000.000
![Page 9: Making things that works with us](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bad2874a79596b2b8b464d/html5/thumbnails/9.jpg)
1.000.000.000
50.000.000.000
![Page 10: Making things that works with us](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bad2874a79596b2b8b464d/html5/thumbnails/10.jpg)
"Things"
![Page 11: Making things that works with us](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bad2874a79596b2b8b464d/html5/thumbnails/11.jpg)
50.000.000.000interconnected
"things"by
2020
http://www.flickr.com/photos/adactio/2337914481
![Page 12: Making things that works with us](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bad2874a79596b2b8b464d/html5/thumbnails/12.jpg)
Social Web Of Things Video
http://www.youtube.com/watch?v=i5AuzQXBsG4
![Page 13: Making things that works with us](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bad2874a79596b2b8b464d/html5/thumbnails/13.jpg)
Let's experiment
![Page 14: Making things that works with us](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bad2874a79596b2b8b464d/html5/thumbnails/14.jpg)
http://www.flickr.com/photos/jurvetson/2798315677
![Page 15: Making things that works with us](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bad2874a79596b2b8b464d/html5/thumbnails/15.jpg)
Monitor my housetemperature
Goal:
![Page 16: Making things that works with us](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bad2874a79596b2b8b464d/html5/thumbnails/16.jpg)
I want to chat with my house
![Page 17: Making things that works with us](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bad2874a79596b2b8b464d/html5/thumbnails/17.jpg)
>: hi househi matteo
>: what's the temperature?36
![Page 18: Making things that works with us](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bad2874a79596b2b8b464d/html5/thumbnails/18.jpg)
>: 4 8 15 16 23 42
If you don’t understand this, you are not a geek!
![Page 19: Making things that works with us](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bad2874a79596b2b8b464d/html5/thumbnails/19.jpg)
Hubot © 2012 GitHub Inc. All rights
Enter Hubot
![Page 20: Making things that works with us](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bad2874a79596b2b8b464d/html5/thumbnails/20.jpg)
Hubot © 2012 GitHub Inc. All rights
A programmable robotthat is controlled through chat
![Page 21: Making things that works with us](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bad2874a79596b2b8b464d/html5/thumbnails/21.jpg)
We can supercharge our house with hubot
![Page 22: Making things that works with us](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bad2874a79596b2b8b464d/html5/thumbnails/22.jpg)
module.exports = (robot) ->
robot.respond /what’s the temperature?/i, (msg) -> msg.http("http://mchouse.it/temperature") .header("Accept", "application/json") .get() (err, res, body) -> msg.send JSON.parse(body)
We can supercharge our house with hubot
How
![Page 23: Making things that works with us](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bad2874a79596b2b8b464d/html5/thumbnails/23.jpg)
In order to ask our temp to hubot, we need to:
1. sense the temp2. get the temp on the web3. build a web API
![Page 24: Making things that works with us](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bad2874a79596b2b8b464d/html5/thumbnails/24.jpg)
From Hubot, I want to do the equivalent of:
>: curl http://mchouse.it/temp
What about JSON
![Page 25: Making things that works with us](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bad2874a79596b2b8b464d/html5/thumbnails/25.jpg)
We are building an API
In Italy,“API” means
“bees”http://www.flickr.com/photos/theseanster93/4056815767
![Page 26: Making things that works with us](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bad2874a79596b2b8b464d/html5/thumbnails/26.jpg)
What do we need to sense my house temperature
![Page 27: Making things that works with us](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bad2874a79596b2b8b464d/html5/thumbnails/27.jpg)
Arduino is an open source microcontroller, that you can use to hack things
http://www.flickr.com/photos/mattrichardson/5029708468/
![Page 28: Making things that works with us](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bad2874a79596b2b8b464d/html5/thumbnails/28.jpg)
TMP36
TMP36
We add a sensor to an Arduino
![Page 29: Making things that works with us](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bad2874a79596b2b8b464d/html5/thumbnails/29.jpg)
TMP36
We add an ethernet shield to connect to the Internet
http://www.flickr.com/photos/snootlab/6052465980/
![Page 30: Making things that works with us](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bad2874a79596b2b8b464d/html5/thumbnails/30.jpg)
What protocol do we use to push our temperature
to our API?
HTTP POST
![Page 31: Making things that works with us](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bad2874a79596b2b8b464d/html5/thumbnails/31.jpg)
http://www.flickr.com/photos/clearlyambiguous/48185613/
HTTP is slow and safe
![Page 32: Making things that works with us](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bad2874a79596b2b8b464d/html5/thumbnails/32.jpg)
We need a fast, binary protocol
http://www.flickr.com/photos/grrphoto/305649629
![Page 33: Making things that works with us](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bad2874a79596b2b8b464d/html5/thumbnails/33.jpg)
likes binary
![Page 34: Making things that works with us](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bad2874a79596b2b8b464d/html5/thumbnails/34.jpg)
What if we need to interconnect our things?
![Page 35: Making things that works with us](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bad2874a79596b2b8b464d/html5/thumbnails/35.jpg)
To build a social web of things we need to react to events.
![Page 36: Making things that works with us](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bad2874a79596b2b8b464d/html5/thumbnails/36.jpg)
We need a publish/subscribe pattern.
![Page 37: Making things that works with us](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bad2874a79596b2b8b464d/html5/thumbnails/37.jpg)
HTTP
![Page 38: Making things that works with us](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bad2874a79596b2b8b464d/html5/thumbnails/38.jpg)
Devices need:• binary protocol
• publish/subscribe
![Page 39: Making things that works with us](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bad2874a79596b2b8b464d/html5/thumbnails/39.jpg)
Binary vs REST“Things” should interact with our lives, and all the technology should be built to make them easy to use.
M2M protocols are ad-hoc, and researchers and businesses focus on low level problems.
![Page 40: Making things that works with us](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bad2874a79596b2b8b464d/html5/thumbnails/40.jpg)
• binary protocol
• publish/subscribe
• topics as the naming system
• royalty free
• open source implementations
• devices exposed to the web
• REST architecture
• URIs as the naming system
• syndication
![Page 41: Making things that works with us](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bad2874a79596b2b8b464d/html5/thumbnails/41.jpg)
MQTT is the state of art protocol for the Internet of Things
![Page 42: Making things that works with us](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bad2874a79596b2b8b464d/html5/thumbnails/42.jpg)
Mosquitto
Really Small Message Broker
![Page 43: Making things that works with us](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bad2874a79596b2b8b464d/html5/thumbnails/43.jpg)
• the base element of the protocol is a topic
• devices and other systems can publish or subscribe to topics
![Page 44: Making things that works with us](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bad2874a79596b2b8b464d/html5/thumbnails/44.jpg)
How to use
on
![Page 45: Making things that works with us](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bad2874a79596b2b8b464d/html5/thumbnails/45.jpg)
Step 1: download PubSubClient, the library for
![Page 46: Making things that works with us](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bad2874a79596b2b8b464d/html5/thumbnails/46.jpg)
on Arduino: Setup
String server = String("qest.me");
PubSubClient client = PubSubClient(server, 1883, callback);
![Page 47: Making things that works with us](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bad2874a79596b2b8b464d/html5/thumbnails/47.jpg)
if (!client.connected()) { client.connect("arduino");}client.loop();
char s[10];itoa(get_temperature(), s, 10);client.publish("temp", s);
on Arduino: publishing
![Page 48: Making things that works with us](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bad2874a79596b2b8b464d/html5/thumbnails/48.jpg)
if (!client.connected()) { client.connect("arduino");}client.loop();
char s[10];itoa(get_temperature(), s, 10);client.publish("temp", s);
on Arduino: publishing
This is called a topic, and it is where we publish
things on MQTT.
![Page 49: Making things that works with us](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bad2874a79596b2b8b464d/html5/thumbnails/49.jpg)
speaks
, Hubot speak HTTP
![Page 50: Making things that works with us](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bad2874a79596b2b8b464d/html5/thumbnails/50.jpg)
speaks
, Hubot speak HTTP
Communication
![Page 51: Making things that works with us](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bad2874a79596b2b8b464d/html5/thumbnails/51.jpg)
QESTDiscover
qest.me
![Page 52: Making things that works with us](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bad2874a79596b2b8b464d/html5/thumbnails/52.jpg)
• MQTT broker
• REST interface
• HTTP semantics
• no QoS
• built in node.js
• crafted by me
QEST
REST Server
Redis
MQTT Server
QEST
Data Layer
HTTP Clients MQTT Clients
![Page 53: Making things that works with us](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bad2874a79596b2b8b464d/html5/thumbnails/53.jpg)
QEST• retains every message received
: MQTT to REST
curl -H "Accept: txt" \ http://qest.me/topics/temp
client.publish("temp", "30");
• every topic has its own URI: /topics/<NAME>
![Page 54: Making things that works with us](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bad2874a79596b2b8b464d/html5/thumbnails/54.jpg)
QEST• transform every HTTP PUT received to a
MQTT message
: REST to MQTT
void callback(char* topic, byte* payload, int length) { ...}PubSubClient(server, 1883, callback);client.subscribe("temp");
curl -X PUT -d '{ "housetemp": 42 }' \-H "Content-Type: application/json" \http://qest.me/topics/temp
• devices can listen directly to MQTT topics
![Page 55: Making things that works with us](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bad2874a79596b2b8b464d/html5/thumbnails/55.jpg)
Web App
DeviceSC
LS
DA
AR
EF
GN
D
IOR
EF
RE
SE
T3V
3P
WM
PW
MP
WM
L
TXRX ON
ICSP
PW
MP
WM
PW
M TX RX
31
21
11
01
9 8DIGITAL
7 6 5 4 3 2 1 0
1
5V GndPOWER
www.arduino.cc
ANALOG INVin 0 1 2 3 4 5
Arduino UNO
IoTBroker
QEST
state-of-artapproach to IoT apps
QEST-basedsolution to IoT apps
Bridge
Web App
DeviceSC
LS
DA
AR
EF
GN
D
IOR
EF
RE
SE
T3V
3P
WM
PW
MP
WM
L
TXRX ON
ICSP
PW
MP
WM
PW
M TX RX
31
21
11
01
9 8DIGITAL
7 6 5 4 3 2 1 0
1
5V GndPOWER
www.arduino.cc
ANALOG INVin 0 1 2 3 4 5
Arduino UNO
![Page 56: Making things that works with us](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bad2874a79596b2b8b464d/html5/thumbnails/56.jpg)
QEST : Scalability
Redis
HTTP/MQTT Clients
REST Server MQTT Server
QESTData Layer
...
Load Balancer
REST Server MQTT Server
QESTData Layer
![Page 57: Making things that works with us](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bad2874a79596b2b8b464d/html5/thumbnails/57.jpg)
JavaScript Apps are often a mess
We mix logic with presentation with persistance.
Is QEST different?http://www.flickr.com/photos/mpirotta/4944504834
Do you like Spaghetti Code?
![Page 58: Making things that works with us](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bad2874a79596b2b8b464d/html5/thumbnails/58.jpg)
Built BDD-style, with Cucumber-js and mocha
Continuous Integration based on Travis-CI
Written in CoffeeScript
Patches are welcome!
http://www.flickr.com/photos/mpirotta/4944504834
QEST:
![Page 59: Making things that works with us](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bad2874a79596b2b8b464d/html5/thumbnails/59.jpg)
http://www.flickr.com/photos/oneaustin/1261907803
Let’s ask something to my house!
![Page 60: Making things that works with us](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bad2874a79596b2b8b464d/html5/thumbnails/60.jpg)
Hubot © 2012 GitHub Inc. All rights
Hubot Integrationmodule.exports = (robot) ->
robot.respond /qest check ([a-z0-9A-Z]+)/i, (msg) -> topic = msg.match[1] if topic? msg.http("http://qest.me/topics/#{topic}") .header("Accept", "application/json") .get() (err, res, body) -> msg.send JSON.parse(body) else msg.send "No topic specified"
![Page 61: Making things that works with us](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bad2874a79596b2b8b464d/html5/thumbnails/61.jpg)
• What devices can a user monitor?
• What devices can 'listen' to the state of other devices?
• Who can access the devices state?
• Is the communication secure?
Security Issues
![Page 62: Making things that works with us](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bad2874a79596b2b8b464d/html5/thumbnails/62.jpg)
We need to interconnect UsersSocial profiles tothe Devices!
![Page 63: Making things that works with us](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bad2874a79596b2b8b464d/html5/thumbnails/63.jpg)
We need OAuthfor Devices!
I’m working on
it!!
![Page 64: Making things that works with us](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bad2874a79596b2b8b464d/html5/thumbnails/64.jpg)
QESTtry
qest.me
![Page 65: Making things that works with us](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bad2874a79596b2b8b464d/html5/thumbnails/65.jpg)
TL;DR• The Internet of Things
will be big
• Devices need binary and pub/sub protocols
• Devs need HTTP API
• QEST does both
![Page 66: Making things that works with us](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bad2874a79596b2b8b464d/html5/thumbnails/66.jpg)
Matteo Collina
Software Engineer
Ph.D. Student
@matteocollina matteocollina.com
![Page 67: Making things that works with us](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bad2874a79596b2b8b464d/html5/thumbnails/67.jpg)
www.mavigex.comwww.wemobi.it
![Page 68: Making things that works with us](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bad2874a79596b2b8b464d/html5/thumbnails/68.jpg)
Credits• Font Awesome for the
Icons.
• Flickr for LOTS of CC images :).
• Balsamiq Mockup for the iPhone Mockup
![Page 69: Making things that works with us](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bad2874a79596b2b8b464d/html5/thumbnails/69.jpg)
Thank You!
![Page 70: Making things that works with us](https://reader033.vdocuments.us/reader033/viewer/2022061220/54bad2874a79596b2b8b464d/html5/thumbnails/70.jpg)
http://www.flickr.com/photos/alexindigo/1606826416
Any Questions?