Skip to main content

Adds pymqtt support to your Python application.

Project description


pymqtt is a mqtt python client library extension meant to facilitate the integration of a MQTT client into your web application. Basically it is a thin wrapper around the paho-mqtt package to simplify MQTT integration in a python application. MQTT is a machine-to-machine (M2M)/”Internet of Things” (IoT) protocol which is designed as a lightweight publish/subscribe messaging transport. It comes very handy when trying to connect multiple IoT devices with each other or monitor and control these devices from one or multiple clients.


Install and update using pip:

$ pip install -U pymqtt

A Simple Example

import logging

from flask import Flask

from pymqtt import Mqtt

logging.basicConfig(format='%(asctime)s %(process)d,%(threadName)s %(filename)s:%(lineno)d [%(levelname)s] %(message)s',
                    datefmt='%Y-%m-%d %H:%M:%S',

logger = logging.getLogger(__name__)

app = Flask(__name__)

app.config.setdefault('MQTT_IP', '')
app.config.setdefault('MQTT_PORT', 1883)
app.config.setdefault('MQTT_USER', 'user')
app.config.setdefault('MQTT_PASSWORD', 'password')

fmqtt = Mqtt()

def hello_world():
    content = 'hello world'
    success = fmqtt.publish('hell world', 'topic', qos=2)
    return 'send %s success %s' % (content, success)

@fmqtt.subscribe(topic='topic', qos=2)
def flask_rabmq_test(body):
    return True

if __name__ == '__main__':

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pymqtt, version 0.0.7
Filename, size File type Python version Upload date Hashes
Filename, size pymqtt-0.0.7-py3-none-any.whl (4.8 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size pymqtt-0.0.7.tar.gz (3.9 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page