From 2e6f6b3f1aa6cc9b15465642b19a8fd9adc8856a Mon Sep 17 00:00:00 2001 From: robert Date: Mon, 15 Feb 2021 23:21:40 +0100 Subject: [PATCH] add outputs --- mqtt_publish_temp.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/mqtt_publish_temp.py b/mqtt_publish_temp.py index e38426d..2593d7f 100644 --- a/mqtt_publish_temp.py +++ b/mqtt_publish_temp.py @@ -47,21 +47,28 @@ while True: # Get Temperature from DHT _, temperature = Adafruit_DHT.read_retry(DHT_SENSOR, DHT_PIN) - + + print("temperature before cut: " + temperature) # cut temperature to xx.xx if more then tow digits after "." t_split = temperature.split(".") if len(t_split[1]) > 2: t_cut = len(t_split[1]) - 2 t_split[1] = t_split[1][:-t_cut] temperature = t_split[0] + "." + t_split[1] + + print("temperature after cut: " + temperature) # Get Humidity from DHT humidity, _ = Adafruit_DHT.read_retry(DHT_SENSOR, DHT_PIN) + + print("humidity before cut: " + humidity) # cut humidity to xx.xx if more then tow digits after "." h_split = humidity.split(".") if len(h_split[1]) > 2: h_cut = len(h_split[1]) - 2 h_split[1] = h_split[1][:-h_cut] humidity = h_split[0] + "." + h_split[1] + + print("humidity after cut: " + humidity) # Publish our data client.publish(temperature_topic, temperature) client.publish(humidity_topic, humidity)