From 6fdcd6c7665ce1ad0a77c982add3bd47ebe4717c Mon Sep 17 00:00:00 2001 From: robert Date: Sun, 14 Feb 2021 21:47:01 +0100 Subject: [PATCH] fix float error --- mqtt_publish_temp.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mqtt_publish_temp.py b/mqtt_publish_temp.py index 9e59b02..9c6b715 100644 --- a/mqtt_publish_temp.py +++ b/mqtt_publish_temp.py @@ -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 \ No newline at end of file + Output data to screen + print temperature + print humidity \ No newline at end of file