Int/String fix
This commit is contained in:
@@ -31,7 +31,6 @@ while True:
|
|||||||
|
|
||||||
#convert to Farenheit
|
#convert to Farenheit
|
||||||
temp = (temp * 1.8) + 32
|
temp = (temp * 1.8) + 32
|
||||||
|
|
||||||
print("Temperature: {}*F Humidity: {}% ".format(temp, humidity))
|
print("Temperature: {}*F Humidity: {}% ".format(temp, humidity))
|
||||||
except RuntimeError as error:
|
except RuntimeError as error:
|
||||||
print(error.args[0])
|
print(error.args[0])
|
||||||
@@ -54,7 +53,7 @@ while True:
|
|||||||
client.connect(broker, port)
|
client.connect(broker, port)
|
||||||
|
|
||||||
#Publish Temp Results
|
#Publish Temp Results
|
||||||
tempMsg = f'{ "temperature": {temp} }'
|
tempMsg = '{ "temperature": {} }'.format(temp)
|
||||||
result = client.publish(tempTopic, tempMsg)
|
result = client.publish(tempTopic, tempMsg)
|
||||||
# result: [0, 1]
|
# result: [0, 1]
|
||||||
status = result[0]
|
status = result[0]
|
||||||
@@ -64,7 +63,8 @@ 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
|
||||||
humidMsg = f'{ "humidity": {humidity} }'
|
|
||||||
|
humidMsg = '{ "humidity": {} }'.format(humidity)
|
||||||
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