fix float error

This commit is contained in:
robert 2021-02-14 21:47:01 +01:00
parent 710eaa90e6
commit 6fdcd6c766

View File

@ -48,10 +48,10 @@ while True:
# Get Temperature from DHT
_, temperature = Adafruit_DHT.read_retry(DHT_SENSOR, DHT_PIN)
temperature = round(temperature, 2)
temperature = round(float(temperature), 2)
# Get Humidity from DHT
humidity, _ = Adafruit_DHT.read_retry(DHT_SENSOR, DHT_PIN)
humidity = round(humidity, 2)
humidity = round(float(humidity), 2)
# Publish our data
client.publish(temperature_topic, temperature)
@ -60,6 +60,6 @@ while True:
time.sleep(30)
# Output data to screen
# print temperature
# print humidity
Output data to screen
print temperature
print humidity