PIR Motion Sensor & EXT0 Wakeup
Human Presence Detection
A passive infrared (PIR) sensor monitors infrared radiation shifts caused by moving human bodies in the kitchen.
Firmware Detection & Wake Logic
- Active Polling: The sensor’s signal is sampled on
GPIO 34. IfanalogRead(PIN_MOTION_SENSOR) > 1000, active status is confirmed andlastMotionTimeis refreshed. - RTC Deep Sleep Wakeup: Before entering deep sleep, the ESP32 configures external interrupt wakeup 0 (EXT0):
esp_sleep_enable_ext0_wakeup((gpio_num_t)WAKEUP_PIN, 1); // Trigger wake on HIGH logic level
This enables the RTC controller to restart the processor immediately when someone enters the kitchen.