'''
Temperature and Humidity measurement with 
ESP32-EVB 
and SNS-DHT11 https://www.olimex.com/Products/Components/Sensors/SNS-DHT11/
or SNS-DHT22 https://www.olimex.com/Products/Components/Sensors/SNS-DHT22/

The sensors are connected to UEXT connector
Pin.1 +3.3V
Pin.2 GND
Pin.9 Output (GPIO14)

'''

from machine import Pin
from time import sleep
import dht 

# comment the line depend on the sensor attached
sensor = dht.DHT11(Pin(14))
#sensor = dht.DHT22(Pin(14))

while True:
  try:
    sleep(2)
    sensor.measure()
    temp = sensor.temperature()
    hum = sensor.humidity()
    temp_f = temp * (9/5) + 32.0
    print('Temperature: %3.1f C' %temp)
    print('Temperature: %3.1f F' %temp_f)
    print('Humidity: %3.1f %%' %hum)
  except OSError as e:
    print('Failed to read sensor.')

