Controlling Devices Using MQTT and Python

MQTT can not only be used for collecting sensor data it can also be used for controlling devices. In this mini workshop we will be creating a device in Python that can be controlled using MQTT. Although our sample device is a simple sensor I have used the same idea and similar code to add MQTT control to Python command line control scripts.

Continue reading

Python MQTT Bridge Project

Many networks will have a local MQTT broker (edge broker) which also connects to a cloud broker. The broker could be configured as an MQTT bridge and relay messages to the cloud broker.

Continue reading

Control Raspberry Pi GPIO Pins Using MQTT

The Raspberry Pi has 40 General purpose Input/output Pins (GPIO) that can be used for controlling external hardware. There are  a number of add-on boards called hats which plug into these pins and provide various sensors. The most common one being the sense hat.

Continue reading

Republish HTML Data Over MQTT

HTTP is the protocol that powers the Web,and is the most common protocol on the Internet. Because http is a request/response protocol a visitor viewing a web page must issue a new request in order to refresh the data.

Continue reading

Logging MQTT Sensor Data to SQLite DataBase With Python

In this project we will create a simple data logger that logs text data to a sqlite database. 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 data (on_message callback) and a worker thread to log the data. A queue is used to move the messages between threads.

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