Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import paho.mqtt.client as paho
- import time
- def on_connect(client, userdata, rc):
- print("Connected with result code " + str(rc))
- def on_publish(client,userdata,result):
- print("data published \n")
- pass
- def on_message(client, userdata, msg):
- print(time.asctime() + " Topic: " + msg.topic + '\nMessage: ' +msg.payload.decode())
- broker="mqtt.eclipse.org"
- port=1883
- client1= paho.Client()
- client1.on_connect = on_connect
- client1.on_publish = on_publish
- client1.on_message = on_message
- client1.connect(broker,port)
- client1.loop_start()
- client1.subscribe("cheerlights")
- while True:
- time.sleep(0.1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement