BillChen235

The Example for Data transferring by   MQTT on local
This commit is contained in:
BillChen235
2023-08-02 02:09:51 +08:00
parent bea476f052
commit 33c66d8741
2 changed files with 4 additions and 5 deletions
+3 -4
View File
@@ -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
+1 -1
View File
@@ -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"