MQTT its the protocol of the Internet of Things (IoT) - so I went on a quest to understand n how MQTT works with devices, sensors and the Internet of Things cloud. To do this, I built a scenario to see if I could get some of my devices to communicate with the IBM IoT Foundation and visualized the sensor data in a graph using a local application on my Notebook. 1st couple of slides show how to connect nest than i wend on to connect my Android Phone and Google Glass.
1. How MQTT can connect devices to the IoT
Markus van Kempen
E: mvk@ca.ibm.com
T: @markusvankempen
2. How MQTT protocol can connect devices to the Internet of Things (#IoT)
- What is MQTT?
-MQTT is a lightweight messaging protocol that supports publish/subscribe
- http://mqtt.org/
- How can it be used to talk to devices?
- How does MQTT work with IoT?
- Other scenarios
-Connecting Android Device to the IoT Cloud
-Connecting GOOGLE GLASS to the IoT Cloud
4. Internet
Scenario overview using MQTT
Publish Hosts messages
Proxy MQTT Client
IoT Cloud / MQTT Broker
Topic: iot-2/type/laptoplan/id/Deviceid/evt/+/fmt/json
5. 1) Get Data from a Sensor e.g Nest
Pull
I am using node (js) and the unofficial nest api
6. 2) Sign up or use a IoT broker
You can use Ibm IoT Cloud
https://internetofthings.ibmcloud.com/#/
Or open source broker like Mosquitto
See mqtt.org for more infos
7. 3) Publish/Send Data via mqtt from you device sensor to IOT cloud / mqtt broker
Publish
client.publish('iot-2/evt/MVK/fmt/json', JSON.stringify(data), function() {});
d": {
"myName": "Markus Infos",
“targettemp" : 72, currenttem 70
}
};
8. 4) Use a mqtt client to subscribe or publish to the broker
There is lots of Mqtt client out there like mqtt.js or a eclipse paho
Subscribe
iot-2/type/mvk-laptoplan/id/00-21-CC-C8-6F-1B/evt/+/fmt/json
9. 5) Subscribe to broker (IoT Cloud) with a mqtt client to visualize the data
Subscribe
iot-2/type/mvk-laptoplan/id/00-21-CC-C8-6F-1B/evt/+/fmt/json
{"d":
{"myName":"Nest Data",
"deviceName":"Bedroom“,
"currentTemp":20.93,“
targetTemp":20}}
10. 6) Implement a command which the device reacts to
{
"d": {
"myName": "Paho client",
"TargetTemp": 72
}
}
iot-2/type/mvk-laptoplan/id/00-21-CC-C8-6F-1B/cmd/MVK/fmt/json
Publish
11. Full Scenario overview using mqtt
Data Publish
Subscribe/
Notify of evt & cmd
CMDPublish
Nest / Proxy
#1 Mqtt Client
#2 Mqtt Client
Visual Display
Distributes
Messages to
subscribers
12. MQTT Client and IoT Cloud
Publish
Distributes
Messages to
subscribers
Subscribe/
Notify of event & cmd
{"d":
{"myName":”Data",
“clientName":“paho“,
“Data":”Hello” ….}}
Publish / Subscribe to Topic iot-2/type/laptoplan/id/Deviceid/evt/+/fmt/json