Part 3 of 13 ESP32MQ-2DHT22Low-Power
System Architecture
Block Diagram
Every wake-up reads the sensors, refreshes the display and goes back to sleep, which is what makes the battery last.
Operational State Machine
- DEEP SLEEP: CPU and peripherals are unpowered. RTC controller listens on GPIO 34 (
ext0 high level).
- WAKE & INITIALIZE: PIR detects movement. MCU boots, configures I2C, initializes LCD backlight, calibrates MQ-2 sensor, and queries DHT22.
- ACTIVE SENSING LOOP: Every 1,000 ms, sensor values are read, formatted, and written to the 16x2 LCD. The 20-second countdown timer resets upon motion.
- TIMEOUT & SLEEP PREPARATION: If no motion is detected for 20 seconds, LCD backlight is turned off, EXT0 interrupt is armed, and deep sleep is entered.