Storing MQTT Messages (Sensor Data) in a SQLite DataBase With Python

In this project we will create a simple data logger to store MQTT messages in a sqlite database. MQTT message Data can be JSON or simple text and is stored as is. The project Consists of two modules. A sql logger class module sql_logger.py The logging script. The script uses a main thread to get the messages(on_message callback) and a worker thread to store the data. A queue is used to move the messages between threads.

Continue reading

Using The Python MQTT-SN Client

The MQTT-SN client used here is the client from the RSMB source files but upgraded to python 3, and modified to work in a similar fashion to the Paho MQTT client. I created it so that I could learn more about MQTT-SN and you should note it is still a work in progress. I would not recommend it in a production environment and would be grateful if you would let me know of any problems with it. Downloads are at the end. The client consists of 4 files. You can copy these source files into the site packages folder under

Continue reading

Understanding IP Multicasting

What is IP Multicasting? -IP multicasting allows a host to send a single packet to thousands of hosts across a routed network i.e. The Internet. It is used mainly for audio (radio) and video distribution. In Networking a packet can be sent to: A single host –Unicast = (TCP and UDP) All hosts -Broadcast – (UDP only) A group of hosts – Multicast -(UDP only)

Continue reading

Checking Active MQTT Client Connections

This tutorial is in response to a question I received on the client connections tutorial page: I’ve been struggling to find a real client connection status tool, dashboard or anything which will show a list of my clients and their connection status. Clearly the broker via the low-level protocol mechanics maintain an MQTT keepalive table for each client — that’s how Last Will and Testament (LWT) is triggered internally by the broker. However how does one display such table? The problem is that you have no way of accessing the connections table on the broker so the only way is to

Continue reading

MQTT Topic and Payload Design

Designing a topic naming and payload scheme will be an important part of any MQTT deployment. In this tutorial we look at possible topic and payload design schemes for MQTT networks.

Continue reading

How to Install The Mosquitto MQTT Broker on Linux

In this tutorial we will look at how you install and run the mosquitto MQTT broker on a Linux server running for example Raspberry Pi or Ubuntu. Here are the steps I used on Ubuntu. sudo apt-add-repository ppa:mosquitto-dev/mosquitto-ppa sudo apt-get update sudo apt-get install mosquitto sudo apt-get install mosquitto-clients sudo apt clean For Raspberry Pi the instructions are taken from  here: wget http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key sudo apt-key add mosquitto-repo.gpg.key Then make the repository available : cd /etc/apt/sources.list.d/ Then , depending on which version of debian you are using: sudo wget http://repo.mosquitto.org/debian/mosquitto-jessie.list sudo wget http://repo.mosquitto.org/debian/mosquitto-stretch.list sudo wget http://repo.mosquitto.org/debian/mosquitto-buster.list Then update apt information: sudo

Continue reading

MQTT Retained Messages Tool

This MQTT testing tool is a simple Python script that will list topics that have a retained message and optionally deletes the retained message. The script can be use from the command prompt by supplying options.

Continue reading