'''
PROJECT TEN
SENSOR NTERFACING: DHT22 Humidity and temperature sensor
Components
----------
- ESP32
- DHT22 or DHT11:
- Facing the grill:
- Pin 1 (left-most) to 3.3V,
- Pin 2 to GPIO4,
- Pin 4 to GND
- (Pin 3 not connected).
Documentation:
Timers: https://docs.micropython.org/en/latest/esp32/quickref.html#timers
Pins and GPIO: https://docs.micropython.org/en/latest/esp32/quickref.html#pins-and-gpio
DHT: https://docs.micropython.org/en/latest/esp32/quickref.html#dht-driver
'''
from machine import Pin, Timer
import dht
dht22 = dht.DHT22(Pin(4))
def take_measurement_isr(event):
dht22.measure()
print("Temp: ", dht22.temperature(), "°C, Humidity: ", dht22.humidity(),"%",end = " \r")
dht_timer = Timer(1)
dht_timer.init(period=1000, mode=Timer.PERIODIC, callback=take_measurement_isr)