Changing Temp test
This commit is contained in:
@@ -8,16 +8,18 @@ from paho.mqtt import client as mqtt_client
|
|||||||
|
|
||||||
sensor = adafruit_dht.DHT11(board.D20)
|
sensor = adafruit_dht.DHT11(board.D20)
|
||||||
|
|
||||||
try:
|
def getValues(sensor):
|
||||||
|
try:
|
||||||
temp = sensor.temperature
|
temp = sensor.temperature
|
||||||
humidity = sensor.humidity
|
humidity = sensor.humidity
|
||||||
|
|
||||||
#convert to Farenheit
|
#convert to Farenheit
|
||||||
temp = (temp * 1.8) + 32
|
temp = (temp * 1.8) + 32
|
||||||
print("Temperature: {}*F Humidity: {}% ".format(temp, humidity))
|
print("Temperature: {}*F Humidity: {}% ".format(temp, humidity))
|
||||||
except RuntimeError as error:
|
except RuntimeError as error:
|
||||||
print(error.args[0])
|
print(error.args[0])
|
||||||
time.sleep(2.0)
|
time.sleep(2.0)
|
||||||
except Exception as error:
|
except Exception as error:
|
||||||
sensor.exit()
|
sensor.exit()
|
||||||
raise error
|
raise error
|
||||||
|
return temp, humidity
|
||||||
Reference in New Issue
Block a user