End Presentation


TWiki Slide Show
Next
Setting up an IoT

Session 3: MQTT and Cayenne

Uli Raich

Formally CERN, Geneva, Switzerland

First slide Previous Next Last slide
COPYRIGHT © 2024 by the contributing authors
Slide 1 of 12





















TWiki Slide Show
Next
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

First slide Previous Next Last slide
COPYRIGHT © 2024 by the contributing authors
Slide 2 of 12





















TWiki Slide Show
Next
Accessing the WiFi network
wifiDemoCode.png

First slide Previous Next Last slide
COPYRIGHT © 2024 by the contributing authors
Slide 3 of 12





















TWiki Slide Show
Next
Accessing the WiFi network from Micropython
wifiConnect.png

First slide Previous Next Last slide
COPYRIGHT © 2024 by the contributing authors
Slide 4 of 12





















TWiki Slide Show
Next
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

mqttPostOfffice.png

First slide Previous Next Last slide
COPYRIGHT © 2024 by the contributing authors
Slide 5 of 12





















TWiki Slide Show
Next
MQTT Demo
mqttDemo.png

First slide Previous Next Last slide
COPYRIGHT © 2024 by the contributing authors
Slide 6 of 12





















TWiki Slide Show
Next
The Micropython library
micropython-lib.png

First slide Previous Next Last slide
COPYRIGHT © 2024 by the contributing authors
Slide 7 of 12





















TWiki Slide Show
Next
A MQTT example using umqtt.simple
umqttDemo.png

First slide Previous Next Last slide
COPYRIGHT © 2024 by the contributing authors
Slide 8 of 12





















TWiki Slide Show
Next
Sending dummy temperature data
mqttDummySensorDemo.png

First slide Previous Next Last slide
COPYRIGHT © 2024 by the contributing authors
Slide 9 of 12





















TWiki Slide Show
Next
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

First slide Previous Next Last slide
COPYRIGHT © 2024 by the contributing authors
Slide 10 of 12





















TWiki Slide Show
Next
Subscribe a callback
subscribeDemo.png

First slide Previous Next Last slide
COPYRIGHT © 2024 by the contributing authors
Slide 11 of 12





















TWiki Slide Show
Next
Callback result

First slide Previous Next Last slide
COPYRIGHT © 2024 by the contributing authors
Slide 12 of 12





















First slide Previous End Presentation






























-- Uli Raich - 2019-05-14

Comments

I Attachment History Action Size Date Who Comment
Unknown file formatodp afnog19-ws-session3.odp r1 manage 5245.0 K 2019-05-15 - 19:13 UliRaich  
PNGpng micropython-lib.png r1 manage 75.2 K 2019-05-14 - 17:31 UliRaich  
PNGpng mqttDemo.png r1 manage 191.3 K 2019-05-14 - 17:23 UliRaich  
PNGpng mqttDummySensorDemo.png r1 manage 74.4 K 2019-05-20 - 18:40 UliRaich  
PNGpng mqttExample.png r2 r1 manage 73.2 K 2019-05-15 - 16:12 UliRaich  
PNGpng mqttPostOfffice.png r1 manage 50.2 K 2019-05-14 - 17:18 UliRaich  
PNGpng realData.png r1 manage 27.7 K 2019-05-15 - 17:12 UliRaich  
PNGpng subscribeDemo.png r1 manage 78.3 K 2019-05-20 - 18:45 UliRaich  
PNGpng umqttDemo.png r2 r1 manage 72.2 K 2019-05-14 - 17:38 UliRaich  
PNGpng wifiConnect.png r1 manage 128.4 K 2019-05-14 - 17:18 UliRaich  
PNGpng wifiDemoCode.png r1 manage 43.8 K 2019-05-15 - 16:14 UliRaich  

This topic: AFNOG > WebHome > AFNOGWorkshop2019 > AFNOG-2019Slides > WorkshopSlides > MQTTAndCayenne
Topic revision: r6 - 2019-05-21 - UliRaich
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback