From 04999a7869695ee3504007f17decdd5c7babee43 Mon Sep 17 00:00:00 2001 From: jerick Date: Mon, 28 Nov 2022 15:52:03 -0500 Subject: [PATCH] Changing Temp test --- mqtt/tempTest.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/mqtt/tempTest.py b/mqtt/tempTest.py index ba80aca..97360ef 100644 --- a/mqtt/tempTest.py +++ b/mqtt/tempTest.py @@ -8,16 +8,18 @@ from paho.mqtt import client as mqtt_client sensor = adafruit_dht.DHT11(board.D20) -try: +def getValues(sensor): + try: temp = sensor.temperature humidity = sensor.humidity #convert to Farenheit temp = (temp * 1.8) + 32 print("Temperature: {}*F Humidity: {}% ".format(temp, humidity)) -except RuntimeError as error: - print(error.args[0]) - time.sleep(2.0) -except Exception as error: - sensor.exit() - raise error \ No newline at end of file + except RuntimeError as error: + print(error.args[0]) + time.sleep(2.0) + except Exception as error: + sensor.exit() + raise error + return temp, humidity \ No newline at end of file