Compare commits
2 Commits
cfd69b682d
...
8cc13e8da0
| Author | SHA1 | Date | |
|---|---|---|---|
| 8cc13e8da0 | |||
| 1772d2e1ce |
@@ -53,10 +53,7 @@ while True:
|
|||||||
client.connect(broker, port)
|
client.connect(broker, port)
|
||||||
|
|
||||||
#Publish Temp Results
|
#Publish Temp Results
|
||||||
#Convert to string so it can be sent to the broker.
|
tempMsg = '{ "temperature": {} }'.format(temp)
|
||||||
temp = str(temp)
|
|
||||||
tempClean = f'{ "temperature": {temp} }'
|
|
||||||
tempMsg = tempClean
|
|
||||||
result = client.publish(tempTopic, tempMsg)
|
result = client.publish(tempTopic, tempMsg)
|
||||||
# result: [0, 1]
|
# result: [0, 1]
|
||||||
status = result[0]
|
status = result[0]
|
||||||
@@ -66,10 +63,7 @@ while True:
|
|||||||
print(f"Failed to send message to topic {tempTopic}")
|
print(f"Failed to send message to topic {tempTopic}")
|
||||||
|
|
||||||
#Publish Humid Results
|
#Publish Humid Results
|
||||||
#Convert to string so it can be sent to the broker.
|
humidMsg = '{ "humidity": {} }'.format(humidity)
|
||||||
humidity = str(humidity)
|
|
||||||
humidClean = f'{ "humidity": {humidity} }'
|
|
||||||
humidMsg = humidClean
|
|
||||||
result = client.publish(humidTopic, humidMsg)
|
result = client.publish(humidTopic, humidMsg)
|
||||||
# result: [0, 1]
|
# result: [0, 1]
|
||||||
status = result[0]
|
status = result[0]
|
||||||
|
|||||||
Reference in New Issue
Block a user