Last active
April 9, 2020 07:55
-
-
Save Veticus/622d60698781645c0e820504d4bdadbf to your computer and use it in GitHub Desktop.
A quick and dirty way to publish a string to a mqtt broker.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get the paho-mqtt library using pip: "pip3 install paho-mqtt" | |
import paho.mqtt.publish as publish | |
def mqttpublish(topic="paho/test/multiple", payload="multiple 2"): | |
msgs = [(topic, payload, 0, False)] | |
publish.multiple(msgs, hostname="broker.hivemq.com") | |
mqttpublish("paho/test/multiple", "TEST01") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment