Skip to content

A production-ready MQTT Client & Data Logger built with Python Tkinter and Paho-MQTT v2.0. Supports Secure Auth, Custom Ports, and Auto CSV Export.

Notifications You must be signed in to change notification settings

PhilYeh1212/Python-MQTT-Data-Logger-GUI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 

Repository files navigation

📡 Python MQTT Data Logger (GUI Source Code)

Python Library License

Stop writing boilerplate MQTT scripts.

A production-ready, GUI-based MQTT Client & Data Logger. Built with Python Tkinter and the latest Paho-MQTT v2.0.

[MQTT Logger Demo] 螢幕擷取畫面 2025-11-19 153828


🚀 Why this tool?

Most free MQTT tools (like MQTT.fx or MQTT Explorer) are great for viewing data, but hard to customize or integrate into your own logic.

This project provides a Full Python Source Code template that handles:

  • Secure Auth: Support for Username/Password & Custom Ports (essential for Cloud Brokers like HiveMQ/EMQX).
  • Paho-MQTT v2.0: Compliant with the latest API standards (no deprecation warnings).
  • Auto CSV Logging: Instantly saves Topic, Payload, and Timestamp to CSV.
  • Subscription Check: Detects if the broker REJECTS your subscription (e.g., wrong wildcard usage).

✨ Features

  • GUI Interface: Clean Tkinter UI. No HTML/JS knowledge required.
  • Non-Blocking: Threaded architecture keeps the UI responsive.
  • Instant Export: Data is saved to mqtt_log.csv in real-time.
  • Error Handling: Visual feedback for connection failures or subscription rejections.

🛠️ Dependencies

Only one external library is required:

pip install paho-mqtt

📥 Download Full Source Code You can get the Complete Source Code (main.py) which includes the full GUI implementation, threading logic, and the Paho v2.0 callback structure.

It is fully commented and ready to be customized for your own automation projects.

👉 Download on Gumroad ($29): [link]

(Includes: main.py, requirements.txt, and Setup Guide)

📖 Code Snippet (Paho v2.0 Logic) The code implements the latest callback API to ensure future compatibility:

Python

# Support for Paho-MQTT v2.0 Callback API
def on_subscribe(self, client, userdata, mid, reason_code_list, properties):
    # Check if subscription was granted (Code >= 128 means failure)
    if reason_code_list[0] >= 128:
        self.log_message(f"❌ Subscription REJECTED!")
    else:
        self.log_message(f"✅ Subscribed successfully.")

# Initialize with VERSION2 to avoid DeprecationWarning
self.client = mqtt.Client(mqtt.CallbackAPIVersion.VERSION2)

👨‍💻 About the Author Phil Yeh - Senior Automation Engineer

My Gumroad Store (More Engineering Tools)

Keywords: MQTT, Python, Paho-MQTT, IoT, Data Logger, GUI, Source Code, Automation, Tkinter, SCADA

About

A production-ready MQTT Client & Data Logger built with Python Tkinter and Paho-MQTT v2.0. Supports Secure Auth, Custom Ports, and Auto CSV Export.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published