from machine import Pin, I2C
from time import sleep
from dht import DHT22
from i2c_lcd import I2cLcd
pir = Pin(14, Pin.IN)
led = Pin(2, Pin.OUT)
dht = DHT22(Pin(4))
i2c = I2C(0, scl=Pin(22), sda=Pin(21))
lcd = I2cLcd(i2c, 0x27, 2, 16)
while True:
dht.measure()
temp = dht.temperature()
if pir.value() == 1:
lcd.clear()
lcd.putstr("INTRUSION\nDETECTED!")
led.on()
elif temp > 35:
lcd.clear()
lcd.putstr("TEMP HIGH {} C".format(temp))
led.on()
else:
lcd.clear()
lcd.putstr("FIELD SAFE : {} C".format(temp))
led.off()
sleep(2)
Loading
esp32-devkit-c-v4
esp32-devkit-c-v4