Checking if conversion is messing it up

This commit is contained in:
2022-11-28 14:15:59 -05:00
parent cfd69b682d
commit 1772d2e1ce

View File

@@ -30,7 +30,7 @@ while True:
humidity = sensor.humidity
#convert to Farenheit
temp = (temp * 1.8) + 32
#temp = (temp * 1.8) + 32
print("Temperature: {}*F Humidity: {}% ".format(temp, humidity))
except RuntimeError as error:
print(error.args[0])
@@ -53,10 +53,7 @@ while True:
client.connect(broker, port)
#Publish Temp Results
#Convert to string so it can be sent to the broker.
temp = str(temp)
tempClean = f'{ "temperature": {temp} }'
tempMsg = tempClean
tempMsg = '{ "temperature": {} }'.format(temp)
result = client.publish(tempTopic, tempMsg)
# result: [0, 1]
status = result[0]
@@ -66,10 +63,7 @@ while True:
print(f"Failed to send message to topic {tempTopic}")
#Publish Humid Results
#Convert to string so it can be sent to the broker.
humidity = str(humidity)
humidClean = f'{ "humidity": {humidity} }'
humidMsg = humidClean
humidMsg = '{ "humidity": {} }'.format(humidity)
result = client.publish(humidTopic, humidMsg)
# result: [0, 1]
status = result[0]