Top Banner
MQTT and SensorThings API MQTT Extension sensorweb.geomatics.ucalgary.ca www.sensorup.com 0.23 litre/minute 0.25 litre/minute 0.27 litre/minute RH: 85 % Temp: 18 Celsius Dr. Steve Liang, Ph.D., P.Eng. Associate Professor, University of Calgary Founder and CEO, SensorUp Inc.
32

MQTT and SensorThings API MQTT Extension

Jan 08, 2017

Download

Internet

SensorUp
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: MQTT and SensorThings API MQTT Extension

MQTT and SensorThings API MQTT Extension

sensorweb.geomatics.ucalgary.cawww.sensorup.com

0.23 litre/minute

0.25 litre/minute0.27 litre/minuteRH: 85 %

Temp: 18 Celsius

Dr. Steve Liang, Ph.D., P.Eng. Associate Professor, University of Calgary Founder and CEO, SensorUp Inc.

Page 2: MQTT and SensorThings API MQTT Extension

About Dr. Steve Liang๏Associate Professor, Geomatics Engineering, Uni. Calgary

๏AITF-Microsoft Industry Research Chair on Open Sensor Web (2011~2014)

๏Chair OGC SensorThings API Standard Working Group

๏Rapporteur, ITU-T SG12/11 on Internet of Things Test Specifications

๏ Founder and CEO, SensorUp Inc

๏Calgary’s Top 40 Under 40

Page 3: MQTT and SensorThings API MQTT Extension

About SensorUp๏We are a leader in Sensor Web and

IoT Platforms

๏We are leading several international IoT standard development efforts (OGC and ITU-T)

๏We are proud member of Eclipse and Open Geospatial Consortium

Page 4: MQTT and SensorThings API MQTT Extension

News - Whiskers๏Whiskers, a new Eclipse

open source project proposal for OGC SensorThings API

๏will includes MQTT support

Page 5: MQTT and SensorThings API MQTT Extension

News - Whiskers๏Whisker is

๏ a Javascript Client Library for SensorThings

๏ a light-weight SensorThings Server for IoT gateways (e.g., Raspberry Pi)

๏ First release - 2016 Q2 or Q3

Page 6: MQTT and SensorThings API MQTT Extension

What will be covered

๏MQTT

๏ SensorThings API MQTT Extension

Page 7: MQTT and SensorThings API MQTT Extension

Why isn’t HTTP enough?

๏HTTP: send a request, receive a response

๏ IoT has fundamentally different challenges

๏ IoT needs a event-oriented paradigm

๏distribute information from 1 to many

๏ get notifications whenever they happen

๏distributing minimal packets of data in huge volumes

๏pushing information over unreliable networks

Page 8: MQTT and SensorThings API MQTT Extension

Why isn’t HTTP enough - 2?

๏ IoT has fundamentally different challenges

๏power consumption is a major concern (battery-powered devices)

๏ responsiveness (near real-time applications)

๏ scalability (50 billion devices!!)

Page 9: MQTT and SensorThings API MQTT Extension

MQTT is…

๏ an ISO standard (ISO/IEC 20922)

๏ an OASIS standard

๏probably the most popular IoT messaging protocol (more in next slide)

๏ efficient and scalable

Page 10: MQTT and SensorThings API MQTT Extension

Messaging Protocols for IoT

1.1%

5.4%

6.8%

8.2%

11.1%

11.5%

18.6%

21.5%

53.0%

63.1%

0.0% 10.0% 20.0% 30.0% 40.0% 50.0% 60.0% 70.0%

None

DDS

Don’t)know

Proprietary

AMQP

XMPP

In7house

CoAP

MQTT

HTTP

What)general)messaging)protocols)do)you)use)in)your) IoT)solution?

Eclipse IoT Developer Survey 2015

Page 11: MQTT and SensorThings API MQTT Extension

MQTT vs HTTPS (power consumption)

http://stephendnicholas.com/posts/power-profiling-mqtt-vs-https

Page 12: MQTT and SensorThings API MQTT Extension

MQTT vs HTTPS (power consumption)

http://stephendnicholas.com/posts/power-profiling-mqtt-vs-https

Page 13: MQTT and SensorThings API MQTT Extension

What MQTT is not…

๏use MQTT doesn’t mean IoT interoperability

๏ It’s part of the interoperability solution

๏ It still needs a data model standard, such as SensorThings API to enable data interoperability

Page 14: MQTT and SensorThings API MQTT Extension

MQTT Topics

๏ the central concept in MQTT to dispatch messages are topics

๏ a topic is a simple string that can have more hierarchy levels, which are separated by a slash (/),

๏ e.g., house/living-room/temperature

๏ topics are the routing information for the MQTT broker

Page 15: MQTT and SensorThings API MQTT Extension

MQTT in a nutshell

MQTT BrokerPublisher Subscribers

Subscribers

Subscribers

Instead of client/server, MQTT has the roles of publisher/subscriber

subscribe: topic1

subscribe: topic1

subscribe: topic1

Page 16: MQTT and SensorThings API MQTT Extension

MQTT in a nutshell

MQTT BrokerPublisher

Subscribers

Subscribers

Publish to: topic1

body

msg

Instead of client/server, MQTT has the roles of publisher/subscriber

msg

msg

msg

Subscribers

Page 17: MQTT and SensorThings API MQTT Extension

MQTT Methods (verbs)

๏Connect: client request a connection with the MQTT broker

๏Disconnect: disconnect notification

๏ Subscribe: subscribe to topics

๏UnSubscribe: unsubscribe from topics

๏Publish: Publish message

Page 18: MQTT and SensorThings API MQTT Extension

Let’s try

๏HiveMQ provides a nice web socket-based client

๏http://www.hivemq.com/demos/websocket-client/

๏ Today I’m gonna use an Eclipse open source tool called mosquitto

๏GIST here: http://gist.github.com/liangsteve/bb7468fb9e97060f4676d3e544c11a77

Page 19: MQTT and SensorThings API MQTT Extension

MQTT Topics cont.๏plus sign (+) is the single level wild card

๏ e.g., a subscription of house/+/temperature will receive messages published to both house/living-room/temperature and house/bed-room/temperature

๏# is multi-level wildcard

๏ e.g., house/# is subscribing to all topics begins with house

Page 20: MQTT and SensorThings API MQTT Extension

MQTT wildcard

MQTT BrokerPublisher Subscribers

Subscribers

SubscribersInstead of client/server, MQTT has the

roles of publisher/subscriber subscribe to:

h/+/t

subscribe to: house/b/+

subscribe to: h/b/t

Page 21: MQTT and SensorThings API MQTT Extension

MQTT wildcard

MQTT BrokerPublisher Subscribers

Subscribers

SubscribersInstead of client/server, MQTT has the

roles of publisher/subscriber h/+/t

h/b/+

h/b/s

publish to topic: h/b/t

Page 22: MQTT and SensorThings API MQTT Extension

MQTT wildcard

MQTT BrokerPublisher Subscribers

Subscribers

SubscribersInstead of client/server, MQTT has the

roles of publisher/subscriber h/+/t

h/b/+

h/b/s

publish to topic: h/a/t

Page 23: MQTT and SensorThings API MQTT Extension

MQTT QoS๏QoS-0: fire-and-forget

๏QoS-1: deliver at least once

๏ the broker stores messages on disk and retries until clients have acknowledged their delivery. (Possibly with duplicates.)

๏QoS-2: deliver exact once

๏have a second acknowledgement round-trip, to ensure that non-idempotent messages can be delivered exactly once

Page 24: MQTT and SensorThings API MQTT Extension

MQTT Retain Flag

๏ Second, messages have a ‘retain’ flag, indicating that they should be stored for delivery to new subscribers. For topics that are infrequently updated, it’s often useful to give new subscribers the last-known message right away (with an indication that it isn’t fresh). Newer retained messages replace previously ones.

Page 25: MQTT and SensorThings API MQTT Extension

What not included in MQTT?

๏What does the topic mean?

๏ h/p/t ??

๏How to interpret the data pushed to you??

SensorThings API MQTT Extension!!

Page 26: MQTT and SensorThings API MQTT Extension

๏MQTT Subscribe v1.0/Datastreams(id)/Observations

SensorThings MQTT Extension MQTT + OData URL Pattern + O&M

URL path tells you how to find metadata, entity name tells you how to

interpret the data

Page 27: MQTT and SensorThings API MQTT Extension

Receive Observations via MQTT

Page 28: MQTT and SensorThings API MQTT Extension

Get Notified when new a THING was created

Page 29: MQTT and SensorThings API MQTT Extension

Demo - Client received notifications when new THINGS join a SensorThings server

Page 30: MQTT and SensorThings API MQTT Extension

Summary

๏MQTT is very suitable for IoT!!

๏ SensorThings API provides the greatness of both HTTP and MQTT.

๏ SensorThings HTTP REST is suitable for historical data and analytics.

๏ SensorThings MQTT is suitable for real-time applications.

Page 31: MQTT and SensorThings API MQTT Extension

References

๏ Introduction to MQTT

๏ https://www.oasis-open.org/committees/download.php/49205/MQTT-OASIS-Webinar.pdf

๏ Eclipse IoT Survey 2015

๏http://www.slideshare.net/IanSkerrett/iot-developer-survey-2015

Page 32: MQTT and SensorThings API MQTT Extension

See you next week!