BillChen235

The Example for Data transferring by   MQTT on local
main
BillChen235 3 years ago
parent bea476f052
commit 33c66d8741

@ -1,6 +1,6 @@
import paho.mqtt.client as mqtt
import time
import numpy as np
@ -34,7 +34,7 @@ def on_publish(self, userdata, mid):
client.topic_ack.append(mid)
host = "192.168.1.110"
host = "127.0.0.1"
port = 1883
topic = "mqtt/pub"
@ -52,8 +52,7 @@ client.loop_start()
publish(topic, "Connect", True)
count = 0
while True:
randTemp = np.random.uniform(25.0, 35.0)
publish(topic, randTemp)
publish(topic, "publish somthing")
time.sleep(2)
print(count)
count += 1

@ -18,7 +18,7 @@ def initialise_clients(cname):
return initialise_client
host = "192.168.0.48"
host = "127.0.0.1"
port = 1883
topic = "data/pub"

Loading…
Cancel
Save