MQTT Class Notes


The outline for the MQTT class

The lecture slides.  The class description

MQTT Chat Demo We can use this during the class. 

Broker and Gui

  1.  The first thing that we need is a GUI tool for making sure that our MQTT server is working.  So please download and install MQTT Explorer.  I really like both it and MQTT because they correctly handle hierarchy. 
  2. The next thing we need is an MQTT broker.  The normal thing is to start with the free one over at   Good to read their page with port numbers. 
  3. You have the MQTT protocol, the web socket protocol, encrypted and unencrypted.  Please connect to topic mqttClass and send 4 messages, one for each protocol.
  4. Should I move these class notes to Github?


Here are the docs for the Python client.  Let us read the connect, on_connect, message, on_message, log methods.  on_disconnect, message_callback_add(), on_unsubscribe, publish, single, multiple, socket. 

Here is the list of Paho Python Examples.  The options example.  is useful.  Here is the important example.  How to create an MQTT Class.  We start with it. 

  1. Connect to the client. 
  2. Subscribe to mqttClass
  3. Publish a message
  4. Python Asyncio Example.  3 different classes.  Just way way too complex.  use two connections and queues, much much easier.  
  5. Okay, now you get your MQTT diploma! See how easy it is. 


Next head over to CloudMQTT, get yourself your own account.  And connect to it. 


  1. In the console, connect to the client. 
  2.  I will give you each a server.  Login  Click on Menu->Node->Manage
  3. Click on Products ->Chat.  Here is our starting point for he Javascript GUI. There is some HTML, CSS, and Javascript.  Click on chat , then view.  That is what it looks like.  Click into the Javascript there re 3 different javascript objects.  app.js is the one we will be working with. Now we just have to connect it up to mQTT.  


A very important part of the class is to discuss what people are doing. 

  1. What do you want to do with MQTT? 
  2. What application are you building?
  3. What broker will you use?
  4. How are you hosting it?
  5.  I released a Simple Topic Logger. No one was interested.  But it gave me the next idea. 
  6.  I am very close to release lets-encypt-mqtt and lets-encrypt-mqtt-gui.  The first one gives you a docker container with NGINX, MQTT and Lets Encrypt.  Give it your domain name and an email address, and it will give you https certificates, and secure channels.   It will have an encrypted and in-the-clear mqtt channel.  It will have 4 web sockets channels.  Half encrypted, half unencrypted.  Half restricted to the same origin host, the other half globally accessible.  It is like mqtt cloud in a docker container. 
  7. A future release ill feature  web editing of the configuration files.   
  8. And then I want to release my simple topic logger.





  MQTT Class Notes   1 item