Created
February 19, 2019 15:36
-
-
Save li2hub/b139a8ee5a017ae6ab9eeafca8a047fd to your computer and use it in GitHub Desktop.
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 time | |
import paho.mqtt.client as paho | |
broker="192.168.x.xxx" #IP of your Raspberry Pi | |
#define callback | |
def on_message(client, userdata, message): | |
time.sleep(1) | |
print("received message =",str(message.payload.decode("utf-8"))) | |
client= paho.Client("client-001") | |
client.on_message=on_message | |
print("connecting to broker ",broker) | |
client.connect(broker) | |
print("subscribing ") | |
client.subscribe("nodemcu") | |
client.loop_forever() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment