53
@matteocollina matteocollina.com IoT Day Trento 2013/04/09 Making things that work with us!

Making things that works with us - First Italian Internet of Things Day

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: Making things that works with us - First Italian Internet of Things Day

@matteocollinamatteocollina.com

IoT Day Trento 2013/04/09

Making things that work with us!

Page 2: Making things that works with us - First Italian Internet of Things Day

Smartphones are changing the world

Page 3: Making things that works with us - First Italian Internet of Things Day

How many people will own a smartphone by 2014

1.000.000.000

Page 4: Making things that works with us - First Italian Internet of Things Day

Did you see it coming

http://www.flickr.com/photos/12738000@N00/360231193/

Page 5: Making things that works with us - First Italian Internet of Things Day

Stevedid.

http://www.flickr.com/photos/noppyfoto/6216399465/

Page 6: Making things that works with us - First Italian Internet of Things Day

Thanks.

http://www.flickr.com/photos/noppyfoto/6216399465/

Page 7: Making things that works with us - First Italian Internet of Things Day

They didn’t!

...

Page 8: Making things that works with us - First Italian Internet of Things Day

What's next(hint: it's a big number)

50.000.000.000

Page 9: Making things that works with us - First Italian Internet of Things Day

1.000.000.000

50.000.000.000

Page 10: Making things that works with us - First Italian Internet of Things Day

50.000.000.000interconnected

"things"by

2020

Page 11: Making things that works with us - First Italian Internet of Things Day

http://www.flickr.com/photos/jurvetson/2798315677

Page 12: Making things that works with us - First Italian Internet of Things Day

Monitor my housetemperature

Goal:

Page 13: Making things that works with us - First Italian Internet of Things Day

I want to chat with my house

Page 14: Making things that works with us - First Italian Internet of Things Day

>: hi househi matteo

>: what's the temperature?19

Page 15: Making things that works with us - First Italian Internet of Things Day

>: 4 8 15 16 23 42

Page 16: Making things that works with us - First Italian Internet of Things Day

Hubot © 2012-2013 GitHub Inc. All rights reserved.

Enter Hubot

Page 17: Making things that works with us - First Italian Internet of Things Day

A programmable robotthat is controlled through chat

Hubot © 2012-2013 GitHub Inc. All rights reserved.

Page 18: Making things that works with us - First Italian Internet of Things Day

We can supercharge our house with hubot

Page 19: Making things that works with us - First Italian Internet of Things Day

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 20: Making things that works with us - First Italian Internet of Things Day

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 21: Making things that works with us - First Italian Internet of Things Day

From Hubot, I want to do the equivalent of:

>: curl http://mchouse.it/temp

What about JSON

Page 22: Making things that works with us - First Italian Internet of Things Day

What protocol do we use to push our temperature

to our API?

HTTP POST

Page 24: Making things that works with us - First Italian Internet of Things Day

We need a fast, binary protocol

http://www.flickr.com/photos/grrphoto/305649629

Page 25: Making things that works with us - First Italian Internet of Things Day

likes binary

Page 26: Making things that works with us - First Italian Internet of Things Day

To build a social web of things we need to react to events.

Page 27: Making things that works with us - First Italian Internet of Things Day

We need a publish/subscribe pattern.

Page 28: Making things that works with us - First Italian Internet of Things Day

HTTP

Page 29: Making things that works with us - First Italian Internet of Things Day

Devices need:• binary protocol

• publish/subscribe

Page 30: Making things that works with us - First Italian Internet of Things Day

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 31: Making things that works with us - First Italian Internet of Things Day

• “things” exposed with binary protocol

• publish/subscribe

• topics as the naming system

• “things” exposed to the web

• request/response

• URIs as the naming system

Page 32: Making things that works with us - First Italian Internet of Things Day

MQTT is the state of art protocol for the Internet of Things

Mosquitto

Really Small Message Broker

Page 33: Making things that works with us - First Italian Internet of Things Day

• the base element of the protocol is a topic

• devices and other systems can publish or subscribe to topics

Page 34: Making things that works with us - First Italian Internet of Things Day

How to use

on

Page 35: Making things that works with us - First Italian Internet of Things Day

Step 1: download PubSubClient, the library for

Page 36: Making things that works with us - First Italian Internet of Things Day

on Arduino: Setup

String server = String("qest.me");

PubSubClient client = PubSubClient(server, 1883, callback);

Page 37: Making things that works with us - First Italian Internet of Things Day

if (!client.connected()) { client.connect("arduino");}client.loop();

char s[10];itoa(get_temperature(), s, 10);client.publish("temp", s);

on Arduino: publishing

Page 38: Making things that works with us - First Italian Internet of Things Day

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 39: Making things that works with us - First Italian Internet of Things Day

speaks

, Hubot speak HTTP

Page 40: Making things that works with us - First Italian Internet of Things Day

speaks

, Hubot speak HTTP

Communication

Page 42: Making things that works with us - First Italian Internet of Things Day

• MQTT broker

• REST interface

• HTTP semantics

• no QoS

• built in node.js

• will support MongoDB, RabbitMQ and many others.

QEST

REST Server

Redis

MQTT Server

QEST

Data Layer

HTTP Clients MQTT Clients

Page 43: Making things that works with us - First Italian Internet of Things Day

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 44: Making things that works with us - First Italian Internet of Things Day

QEST• transform every HTTP PUT received into 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 45: Making things that works with us - First Italian Internet of Things Day

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 46: Making things that works with us - First Italian Internet of Things Day

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 47: Making things that works with us - First Italian Internet of Things Day

• 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 48: Making things that works with us - First Italian Internet of Things Day

We need OAuthfor Devices!

I’m working on

it!!

Page 49: Making things that works with us - First Italian Internet of Things Day

TL;DR• The Internet of Things

will be big

• Devices need binary and pub/sub protocols

• Devs need HTTP API

• QEST does both

Page 50: Making things that works with us - First Italian Internet of Things Day

Matteo Collina

Ph.D. Student @ University of Bologna

@matteocollina matteocollina.com

Page 51: Making things that works with us - First Italian Internet of Things Day

Credits• Font-Awesome for the

Icons.

• Flickr for the CC images.

• Balsamiq Mockup for the iPhone Mockup.

• Unibo for my Ph.D.

Page 52: Making things that works with us - First Italian Internet of Things Day

Matteo Collina ([email protected])

Thank You!

@matteocollina

http://www.flickr.com/photos/axel-d/479627824/

Page 53: Making things that works with us - First Italian Internet of Things Day

http://www.flickr.com/photos/alexindigo/1606826416

Any Questions?