I am continually creating scripts for testing and demo purposes,and doing small projects to gain a better understanding of MQTT and associated technologies.
In this section I will take you though some example projects and scripts that I have created.
We will look at how they work and you will be able to download them, use and modify them to help with your own projects.
You should note that the Scripts are for educational purposes,but you are free to use them in your own projects without restriction.
Grateful any comments/problems or requests.
Simple Controllable MQTT Sensor Simulator in Python -A very simple two state sensor using python , that can be controlled externally using MQTT.
Simple MQTT Sensor Data Logger using SQL – This script Logs sensor data to a a sqllite database .
Simple MQTT Data Logger – This script Logs data to a files as simple text or JSON encoded data .
How to Send a File Using MQTT– Reads a file from disk and sends it using MQTT. It uses a file hash to check that the file is received ok.
Encrypting MQTT Payloads with Python – Example Code. -Payload encryption is easier to implement than SSL link encryption. This is an example Python script that implements MQTT payload encryption..
MQTT Ping -Python utility like the traditional IP Ping for testing if a broker is up.
The Retained Messages script will list all retained messages for a topic hierarchy and optionally delete them.
Retained Messages Utility–
Two scripts one for displaying and optionally deleting retained messages on a topic tree. The other is used for creating topics with retained messages for testing purposes. Tutorial here. includes link to download the scripts
MQTT- Monitor -Monitors Selected topics
This is very useful tool for monitoring topics on a broker. I use it frequently when testing.
By default it only display changed messages.
Type python mqtt-monitor.py -h
- Can add multiple topics by repeated use of -t option
- Use -v no to display only changed messages
- Use -c 100 to stop after 100 seconds
- Use -q value (0 or 1 or 2) to set the QOS of all topics
- Use -d yes to turn on debugging mode
The script is designed to be run from the command line. Download here