import machine
import utime
import dht
# Initialize DHT22 sensor on GPIO15 (Pin 20)
sensor = dht.DHT22(machine.Pin(15))
# Initialize potentiometer on GPIO27 (Pin 32)
pot = machine.ADC(27)
while True:
try:
sensor.measure()
temp = sensor.temperature()
hum = sensor.humidity()
light_intensity = pot.read_u16() # Read value from potentiometer
print('Temperature: {}C, Humidity: {}%, Light Intensity: {}'.format(temp, hum, light_intensity))
except OSError as e:
print('Failed to read sensor.')
utime.sleep(2)