Slide 1: Setting up an IoT
Session 3: MQTT and Cayenne
Uli Raich
Formally CERN, Geneva, Switzerland
Slide 2: The Network Layers
The WeMos D1 mini has a built-in WiFi interface
In order to communicate with other IoT nodes we must therefore
connect to the WiFi network first
On top of WiFi we will run a TCP session
On top of TCP we will run the MQTT protocol
On top of MQTT we have dedicated topics and payloads imposed by Cayenne
Slide 3: Accessing the WiFi network
Slide 4: Accessing the WiFi network from Micropython
Slide 5: MQTT
MQTT (Message Queuing Telemetry Transport: a publish-subscribe based
message protocol running of top of TCP.
A processor can subscribe to messages of a certain “topic” and/or it can push its
results on a certain topic
Slide 6: MQTT Demo
Slide 7: The Micropython library
Slide 8: A MQTT example using umqtt.simple
Slide 9: Sending dummy temperature data
Slide 10: Receiving commands
Receiving commands is a bit more tricky! We must:
- Write a callback function and register it with the MQTT client
- This function takes 2 arguments:
- The topic
- The payload
- Subscribe to the topic
- Wait forever. The callback function will be executed when a message with the
topic we subscribed to, will arrive
Slide 11: Subscribe a callback
Slide 12: Callback result
--
Uli Raich - 2019-05-14
Comments