1import Adafruit_DHT
2
3DHT_SENSOR = Adafruit_DHT.DHT22
4DHT_PIN = 4
5
6while True:
7 humidity, temperature = Adafruit_DHT.read_retry(DHT_SENSOR, DHT_PIN)
8
9 if humidity is not None and temperature is not None:
10 print("Temp={0:0.1f}*C Humidity={1:0.1f}%".format(temperature, humidity))
11 else:
12 print("Failed to retrieve data from humidity sensor")