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 readingCategory: Python MQTT-Projects
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 readingHow to Log MQTT Sensor Data by Topic Using Python
The MQTT sensor data logger logs data on all monitored topics to the same log files. If the data need to be split into topics then it will need to be done by the log analyser software.
Continue readingRepublish 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 readingLogging 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 readingChecking 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 readingHow to Send and Receive JSON Data Over MQTT with Python
Encoding data in JSON is popular for sending data over the Internet, and also for storing data. You can encode a Python List or dictionary in JSON format and then decode it back into a list or dictionary as illustrated in the diagram below:
Continue readingHow to Send a File Using MQTT and Python
In this tutorial will will look at how we can send a file or picture using MQTT. The script is written in Python and the approach I used was to send the file as bytes.
Continue readingHow to Encrypt MQTT Payloads with Python – Example Code
Encrypting the MQTT payload rather than the link has the advantage that the data is encrypted end to end and not just between the broker and the client.
Continue readingLogging MQTT Sensor Data Using Python
In this project we will create a simple data logger that logs IOT sensor/device data in JSON format to a text log file. The project Consists of two main modules. A logger class module mlogger.py The logging script mqtt-data-logger.py It also has helper module commands.py which gets and parses command line arguments. Note: There is also the Simple Python MQTT Topic Logger which logs data based on topic that may be more suitable for your project. Logger Class The class is implemented in a module called m_logger.py (message logger). It can be used for logging data from any source not
Continue reading