Last active
March 1, 2018 06:02
-
-
Save LarsBergqvist/0bbbd07aea514f12118dcbc5c3874f17 to your computer and use it in GitHub Desktop.
paho mqtt subscriber example
This file contains 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
import paho.mqtt.client as mqtt | |
def on_connect(client, userdata, flags, rc): | |
print("Connected with result code "+str(rc)) | |
client.subscribe("Hellos/+") | |
def on_message(client, userdata, msg): | |
print(msg.topic+" "+str(msg.payload)) | |
client = mqtt.Client() | |
client.on_connect = on_connect | |
client.on_message = on_message | |
client.connect("192.168.1.16", 1883, 60) | |
client.loop_forever() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment