import dht
import machine
import utime
dht_pin = machine.Pin(15, machine.Pin.IN, machine.Pin.PULL_UP)
dht_sensor = dht.DHT22(dht_pin)
ldr_pin = machine.Pin(26, machine.Pin.IN)
def read_ldr():
return ldr_pin.value()
while True:
dht_sensor.measure()
temperature_celsius = dht_sensor.temperature()
humidity = dht_sensor.humidity()
print("Temperature: {:.1f} C".format(temperature_celsius))
print("Humidity: {:.1f} %".format(humidity))
ldr_value = read_ldr()
print("LDR Value:", ldr_value)
utime.sleep(2)