@matteocollina   matteocollina.com Making things that work with us!Codemotion Venezia 2012/11/17
Smartphones arechanging the world
How many people will owna smartphone by 2014       1.000.000.000
Did you seeit coming   http://www.flickr.com/photos/12738000@N00/360231193/
Stevedid.        http://www.flickr.com/photos/noppyfoto/6216399465/
Thanks.          http://www.flickr.com/photos/noppyfoto/6216399465/
They didn’t!    ...
Whats next              (hint: its a big number)    50.000.000.000
50.000.000.0001.000.000.000
"Things"
http://www.flickr.com/photos/adactio/2337914481                             50.000.000.000                                ...
Social Web OfThings Videohttp://www.youtube.com/watch?v=i5AuzQXBsG4
Lets experiment
http://www.flickr.com/photos/jurvetson/2798315677
Goal:   Monitor my   house   temperature
I want tochat withmy house
>: hi househi matteo>: whats thetemperature?36
>: 4 8 15 16 23 42 If you don’t understand this, you are not a geek!
Enter Hubot              Hubot © 2012 GitHub Inc. All rights
A programmable robotthat is controlled throughchat                      Hubot © 2012 GitHub Inc. All rights
We can supercharge our house with hubot
We can supercharge our house with hubot                  Howmodule.exports = (robot) ->  robot.respond /what’s the tempera...
In order to ask our tempto hubot, we need to: 1. sense the temp 2. get the temp on the web 3. build a web API
From Hubot, I want to dothe equivalent of:       >: curl http://mchouse.it/temp What about JSON
We are building an API      In Italy,     “API” means        “bees”                   http://www.flickr.com/photos/thesean...
What do we need tosense my housetemperature
Arduino is an opensource microcontroller,that you can use tohack things                  http://www.flickr.com/photos/mattr...
We add a sensor to an Arduino                    TMP                     36                                TMP            ...
We add an ethernet shield to  connect to the Internet                                                          TMP        ...
What protocol do we useto push our temperature      to our API?   HTTP POST
HTTP is slow and safe               http://www.flickr.com/photos/clearlyambiguous/48185613/
We need afast, binaryprotocol               http://www.flickr.com/photos/grrphoto/305649629
likes binary
What if weneed tointerconnectour things?
To build asocial web ofthings weneed to reactto events.
We need apublish/subscribepattern.
HTTP
Devices need:• binary protocol• publish/subscribe
Binary vs RESTM2M protocols are     “Things” shouldad-hoc, and           interact with ourresearchers and       lives, and...
• “things” exposed       • “things” exposed  with binary protocol     to the web• publish/subscribe      • request/respons...
MQTT is thestate of artprotocol for theInternet ofThings
Mosquitto Really SmallMessage Broker
• the base element of the protocol is a topic• devices and other systems can publish or  subscribe to topics
How to use on
Step 1: downloadPubSubClient, the      library for
on Arduino: SetupString server = String("qest.me");PubSubClient client =  PubSubClient(server,               1883,        ...
on Arduino: publishingif (!client.connected()) {  client.connect("arduino");}client.loop();char s[10];itoa(get_temperature...
on Arduino: publishingif (!client.connected()) {  client.connect("arduino");}client.loop();      This is called a topic,  ...
speaks, Hubot speak HTTP
speaksCommunication, Hubot speak HTTP
DiscoverQESTqest.me
QEST                         HTTP Clients           MQTT Clients• MQTT broker• REST interface                      REST Se...
QEST : MQTT to REST• retains every message received                client.publish("temp", "30");• every topic has its own ...
QEST : REST to MQTT• transform every HTTP PUT received to a  MQTT message          curl -X PUT -d { "housetemp": 42 }     ...
state-of-art                                                              QEST-based              approach to IoT apps    ...
QEST : Scalability                        HTTP/MQTT Clients                          Load Balancer   REST Server   MQTT Se...
Do you likeSpaghettiCode?JavaScript Apps areoften a messWe mix logic withpresentation withpersistance.Is QEST different?  ...
QEST:Built BDD-style, withCucumber-js and mochaContinuous Integrationbased on Travis-CIWritten in CoffeeScriptPatches are ...
Let’s ask something    to my house!              http://www.flickr.com/photos/oneaustin/1261907803
Hubot Integrationmodule.exports = (robot) ->  robot.respond /qest check ([a-z0-9A-Z]+)/i, (msg) ->    topic = msg.match[1]...
Security Issues• What devices can a user monitor?• What devices can listen to the  state of other devices?• Who can access...
We need tointerconnect UsersSocial profiles tothe Devices!
We need OAuth for Devices!      I’m   working on      it!!
tryQESTqest.me
TL;DR• The Internet of Things  will be big• Devices need binary  and pub/sub protocols• Devs need HTTP API• QEST does both
Matteo Collina                 Software Engineer @                 Mavigex                 Ph.D. Student @                ...
Credits• Font Awesome for the  Icons.• Flickr for LOTS of CC  images :).• Balsamiq Mockup for  the iPhone Mockup
@matteocollinaThank You! Matteo Collina (matteo.collina2@unibo.it)                                                http://w...
Any Questions?            http://www.flickr.com/photos/alexindigo/1606826416
Upcoming SlideShare
Loading in...5
×

Making things that works with us codemotion

3,937

Published on

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.

0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
3,937
On Slideshare
0
From Embeds
0
Number of Embeds
9
Actions
Shares
0
Downloads
15
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Making things that works with us codemotion

  1. 1. @matteocollina matteocollina.com Making things that work with us!Codemotion Venezia 2012/11/17
  2. 2. Smartphones arechanging the world
  3. 3. How many people will owna smartphone by 2014 1.000.000.000
  4. 4. Did you seeit coming http://www.flickr.com/photos/12738000@N00/360231193/
  5. 5. Stevedid. http://www.flickr.com/photos/noppyfoto/6216399465/
  6. 6. Thanks. http://www.flickr.com/photos/noppyfoto/6216399465/
  7. 7. They didn’t! ...
  8. 8. Whats next (hint: its a big number) 50.000.000.000
  9. 9. 50.000.000.0001.000.000.000
  10. 10. "Things"
  11. 11. http://www.flickr.com/photos/adactio/2337914481 50.000.000.000 interconnected "things" by 2020
  12. 12. Social Web OfThings Videohttp://www.youtube.com/watch?v=i5AuzQXBsG4
  13. 13. Lets experiment
  14. 14. http://www.flickr.com/photos/jurvetson/2798315677
  15. 15. Goal: Monitor my house temperature
  16. 16. I want tochat withmy house
  17. 17. >: hi househi matteo>: whats thetemperature?36
  18. 18. >: 4 8 15 16 23 42 If you don’t understand this, you are not a geek!
  19. 19. Enter Hubot Hubot © 2012 GitHub Inc. All rights
  20. 20. A programmable robotthat is controlled throughchat Hubot © 2012 GitHub Inc. All rights
  21. 21. We can supercharge our house with hubot
  22. 22. We can supercharge our house with hubot Howmodule.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)
  23. 23. In order to ask our tempto hubot, we need to: 1. sense the temp 2. get the temp on the web 3. build a web API
  24. 24. From Hubot, I want to dothe equivalent of: >: curl http://mchouse.it/temp What about JSON
  25. 25. We are building an API In Italy, “API” means “bees” http://www.flickr.com/photos/theseanster93/4056815767
  26. 26. What do we need tosense my housetemperature
  27. 27. Arduino is an opensource microcontroller,that you can use tohack things http://www.flickr.com/photos/mattrichardson/5029708468/
  28. 28. We add a sensor to an Arduino TMP 36 TMP 36
  29. 29. We add an ethernet shield to connect to the Internet TMP 36 http://www.flickr.com/photos/snootlab/6052465980/
  30. 30. What protocol do we useto push our temperature to our API? HTTP POST
  31. 31. HTTP is slow and safe http://www.flickr.com/photos/clearlyambiguous/48185613/
  32. 32. We need afast, binaryprotocol http://www.flickr.com/photos/grrphoto/305649629
  33. 33. likes binary
  34. 34. What if weneed tointerconnectour things?
  35. 35. To build asocial web ofthings weneed to reactto events.
  36. 36. We need apublish/subscribepattern.
  37. 37. HTTP
  38. 38. Devices need:• binary protocol• publish/subscribe
  39. 39. Binary vs RESTM2M protocols are “Things” shouldad-hoc, and interact with ourresearchers and lives, and all thebusinesses focus on technology shouldlow level problems. be built to make them easy to use.
  40. 40. • “things” exposed • “things” exposed with binary protocol to the web• publish/subscribe • request/response• topics as the naming • URIs as the system naming system
  41. 41. MQTT is thestate of artprotocol for theInternet ofThings
  42. 42. Mosquitto Really SmallMessage Broker
  43. 43. • the base element of the protocol is a topic• devices and other systems can publish or subscribe to topics
  44. 44. How to use on
  45. 45. Step 1: downloadPubSubClient, the library for
  46. 46. on Arduino: SetupString server = String("qest.me");PubSubClient client = PubSubClient(server, 1883, callback);
  47. 47. on Arduino: publishingif (!client.connected()) { client.connect("arduino");}client.loop();char s[10];itoa(get_temperature(), s, 10);client.publish("temp", s);
  48. 48. on Arduino: publishingif (!client.connected()) { client.connect("arduino");}client.loop(); This is called a topic, and it is where we publishchars[10]; MQTT. things onitoa(get_temperature(), s, 10);client.publish("temp", s);
  49. 49. speaks, Hubot speak HTTP
  50. 50. speaksCommunication, Hubot speak HTTP
  51. 51. DiscoverQESTqest.me
  52. 52. QEST HTTP Clients MQTT Clients• MQTT broker• REST interface REST Server MQTT Server• HTTP semantics QEST• no QoS Data Layer• built in node.js• crafted by me Redis
  53. 53. QEST : MQTT to REST• retains every message received client.publish("temp", "30");• every topic has its own URI: /topics/<NAME> curl -H "Accept: txt" http://qest.me/topics/temp
  54. 54. QEST : REST to MQTT• transform every HTTP PUT received to a MQTT message curl -X PUT -d { "housetemp": 42 } -H "Content-Type: application/json" http://qest.me/topics/temp• devices can listen directly to MQTT topics void callback(char* topic, byte* payload, int length) { ... } PubSubClient(server, 1883, callback); client.subscribe("temp");
  55. 55. state-of-art QEST-based approach to IoT apps solution to IoT apps Web App Web App Bridge QEST IoT Device 3 2 1 0 9 8 7 6 5 4 3 2 1 0 GND SCL AREF SDA 1 1 1 1 DIGITAL RX TX PWM PWM PWM PWM PWM PWM L TX Arduino UNO ON Broker RX 1 ICSP www.arduino.cc RESET IOREF POWER ANALOG IN 3V3 5V Gnd Vin 0 1 2 3 4 5 Device 3 2 1 0 9 8 7 6 5 4 3 2 1 0 GND SCLAREF SDA 1 1 1 1 DIGITAL RX TX PWM PWM PWM PWM PWM PWM L TX RX Arduino UNO ON 1 ICSP www.arduino.cc RESET IOREF POWER ANALOG IN 3V3 5V Gnd Vin 0 1 2 3 4 5
  56. 56. QEST : Scalability HTTP/MQTT Clients Load Balancer REST Server MQTT Server REST Server MQTT Server QEST Data Layer ... QEST Data Layer Redis
  57. 57. Do you likeSpaghettiCode?JavaScript Apps areoften a messWe mix logic withpresentation withpersistance.Is QEST different? http://www.flickr.com/photos/mpirotta/4944504834
  58. 58. QEST:Built BDD-style, withCucumber-js and mochaContinuous Integrationbased on Travis-CIWritten in CoffeeScriptPatches are welcome! http://www.flickr.com/photos/mpirotta/4944504834
  59. 59. Let’s ask something to my house! http://www.flickr.com/photos/oneaustin/1261907803
  60. 60. 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" Hubot © 2012 GitHub Inc. All rights
  61. 61. Security Issues• 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?
  62. 62. We need tointerconnect UsersSocial profiles tothe Devices!
  63. 63. We need OAuth for Devices! I’m working on it!!
  64. 64. tryQESTqest.me
  65. 65. TL;DR• The Internet of Things will be big• Devices need binary and pub/sub protocols• Devs need HTTP API• QEST does both
  66. 66. Matteo Collina Software Engineer @ Mavigex Ph.D. Student @ University of Bologna@matteocollina matteocollina.com
  67. 67. Credits• Font Awesome for the Icons.• Flickr for LOTS of CC images :).• Balsamiq Mockup for the iPhone Mockup
  68. 68. @matteocollinaThank You! Matteo Collina (matteo.collina2@unibo.it) http://www.flickr.com/photos/axel-d/479627824/
  69. 69. Any Questions? http://www.flickr.com/photos/alexindigo/1606826416
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×