-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathVirtual_Publisher_Kits.py
More file actions
44 lines (36 loc) · 1.71 KB
/
Virtual_Publisher_Kits.py
File metadata and controls
44 lines (36 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import paho.mqtt.client as mqtt
import time
# set broker ip address
ip = "192.168.0.53"
#ip = "192.168.0.23"
# set client number
num = 10
# client array
client = []
for i in range(0, num):
client.append(mqtt.Client("Real"+str(i)))
client[i].connect(ip)
print("All publishers connected. \n")
while(True):
#for i in range(1, 10):
# client[i].publish("EngineeringCenter/"+str(101+i)+"/fire","1" , qos = 0)
# client[i].publish("EngineeringCenter/"+str(101+i)+"/gas","1" , qos = 0)
# client[i].publish("EngineeringCenter/"+str(101+i)+"/humid","55" , qos = 0)
# client[i].publish("EngineeringCenter/"+str(101+i)+"/vibrate","1" , qos = 0)
# client[i].publish("EngineeringCenter/"+str(101+i)+"/temperature","24" , qos = 0)
for i in range(2, 10):
client[i].publish("TruthCenter/"+str(101+i)+"/fire","1" , qos = 0)
client[i].publish("TruthCenter/"+str(101+i)+"/gas","1" , qos = 0)
client[i].publish("TruthCenter/"+str(101+i)+"/humid","55" , qos = 0)
client[i].publish("TruthCenter/"+str(101+i)+"/vibrate","1" , qos = 0)
client[i].publish("TruthCenter/"+str(101+i)+"/temperature","24" , qos = 0)
# FutureCenter Code
# if you want to use this code, have to set num 29
# for i in range(20, 29):
# client[i].publish("FutureCenter/"+str(81+i)+"/fire","1" , qos = 0)
# client[i].publish("FutureCenter/"+str(81+i)+"/gas","1" , qos = 0)
# client[i].publish("FutureCenter/"+str(81+i)+"/humid","55" , qos = 0)
# client[i].publish("FutureCenter/"+str(81+i)+"/vibrate","1" , qos = 0)
# client[i].publish("FutureCenter/"+str(81+i)+"/temperature","24" , qos = 0)
print("Fire Detection KITs message send. \n")
time.sleep(1)