Skip to main content

py2mqtt

Interfaces for Python to transmit, receive, and act on data over an MQTT connection.

To install: pip install py2mqtt. If running from source, you must install paho-mqtt and stream2py.

You must also have access to an MQTT broker (usually on localhost).

Installing an MQTT broker on OS X

https://formulae.brew.sh/formula/mosquitto

$ brew install mosquitto

$ brew services start mosquitto

Audio playback demo

  1. Ensure you have pyaudio installed. If not: pip install pyaudio + some system installs (http://people.csail.mit.edu/hubert/pyaudio/).
  2. Run the file py2mqtt/examples/mqtt_pcm_stream_playback.py.
from py2mqtt.examples.mqtt_writer import MQTTTopicWriter
from py2mqtt import sample_data_dir_path
import os

# Enter a filename with PCM data (or use this default one)
# For this demo, should be 16-bit, 2 channels, 44100 Hz
src_wav_filepath = os.path.join(sample_data_dir_path, 'drumloop.wav')

topic = 'test_topic'
chk_size = 2048  # you may modify these values
n_chunks = 1000
with open(src_wav_filepath, 'rb') as fp:
    writer = MQTTTopicWriter(topic, fp)
    for i in range(n_chunks):
        writer.push(fp.read(chk_size))

You should hear the WAV file played back after being chunked, passed through the MQTT broker as a series of messages, and reassembled by the reader.

Metadata

Release files for py2mqtt 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for py2mqtt 0.0.2
File Size Uploaded Provenance Actions
py2mqtt-0.0.2.tar.gz 510.0 kB Without provenance Details for py2mqtt-0.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for py2mqtt 0.0.2
File Interpreter ABI Platform Actions
py2mqtt-0.0.2-py3-none-any.whl Python 3 none any Details for py2mqtt-0.0.2-py3-none-any.whl

Total release size: 1.0 MB

Release files / py2mqtt-0.0.2.tar.gz

Download URL py2mqtt-0.0.2.tar.gz
Size 510.0 kB
Tags Source
SHA-256 checksum
How to use checksums
33f36966827bf1b297dbe8e4fdd38107c26056a390ff19add937215b9d48d551
BLAKE2b-256 checksum
How to use checksums
b167897cbb80877f0d0b99ad5e670124fbfde09513b7ad2c995058e5ff5e6bc3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / py2mqtt-0.0.2-py3-none-any.whl

Download URL py2mqtt-0.0.2-py3-none-any.whl
Size 511.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
334bfb2e073f8bf8cee891b9a25985851e72715f2ae0f0e5dbd39a2368295d5d
BLAKE2b-256 checksum
How to use checksums
e8c7c3551ae472ef7da3950b0d0fe23c206b36c675b91cc7c0d2ea43db3e8b2d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for py2mqtt 0.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page