This is used to light a small room whenever movement is detected, using a PIR sensor (QB041/QB066 PIR), an esp32h2, fairy led lights and a bc337 to turn the lights on/off
Everything is battery operated (3xAA)
It is implemented as a finite state machine with 3 states and utilizes deep sleep to minimize power consumption
This is an alternative to https://github.com/mrnul/light
- PIR: PIR is LOW (no motion)
- Action: Light OFF
- Transition:
- → STATE2 when PIR becomes HIGH (motion detected)
- PIR: PIR is HIGH (motion detected)
- Action: Light ON
- Transition:
- → STATE3 when PIR becomes LOW (no motion)
- PIR: PIR is LOW (no motion)
- Action: Light remains ON
- Transition:
- → STATE2 if PIR becomes HIGH (motion resumes)
- → STATE1 if timeout expires
stateDiagram-v2
STATE1: STATE1 - Light OFF
STATE2: STATE2 - Motion - Light ON
STATE3: STATE3 - No Motion - Grace Period - Light ON
STATE1 --> STATE2: PIR HIGH
STATE2 --> STATE3: PIR LOW
STATE3 --> STATE2: PIR HIGH
STATE3 --> STATE1: Timeout