Skip to content

Instantly share code, notes, and snippets.

@jyotendra
Created November 12, 2019 02:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jyotendra/2b3b0a993f2f4b60e97eb6026004f54d to your computer and use it in GitHub Desktop.
Save jyotendra/2b3b0a993f2f4b60e97eb6026004f54d to your computer and use it in GitHub Desktop.
This gist demonstrates a simple-publisher and a simple-subscriber
import paho.mqtt.publish as publish
publish.single("bv_solutions/test", "payload", hostname="mqtt.eclipse.org")
import paho.mqtt.subscribe as subscribe
topics = ['bv_solutions/test']
m = subscribe.simple(topics, hostname="mqtt.eclipse.org", retained=False, msg_count=1)
if m is not list:
m = [m]
for a in m:
print(a.topic)
print(a.payload)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment