Session 3: MQTT and Cayenne
Uli Raich
Formally CERN, Geneva, Switzerland
COPYRIGHT © 2025 by the contributing authors
Slide 1 of 12
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
COPYRIGHT © 2025 by the contributing authors
Slide 2 of 12
Accessing the WiFi network
COPYRIGHT © 2025 by the contributing authors
Slide 3 of 12
Accessing the WiFi network from Micropython
COPYRIGHT © 2025 by the contributing authors
Slide 4 of 12
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
COPYRIGHT © 2025 by the contributing authors
Slide 5 of 12
COPYRIGHT © 2025 by the contributing authors
Slide 6 of 12
COPYRIGHT © 2025 by the contributing authors
Slide 7 of 12
A MQTT example using umqtt.simple
COPYRIGHT © 2025 by the contributing authors
Slide 8 of 12
Sending dummy temperature data
COPYRIGHT © 2025 by the contributing authors
Slide 9 of 12
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
COPYRIGHT © 2025 by the contributing authors
Slide 10 of 12
COPYRIGHT © 2025 by the contributing authors
Slide 11 of 12
COPYRIGHT © 2025 by the contributing authors
Slide 12 of 12
--
Uli Raich - 2019-05-14
Comments
This topic: AFNOG
> WebHome >
AFNOGWorkshop2019 >
AFNOG-2019Slides >
WorkshopSlides > MQTTAndCayenne
Topic revision: r6 - 2019-05-21 - UliRaich

Copyright © 2008-2025 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki?
Send feedback