I'm thinking to create a house Alarm System with ESPEasy.
For now I have a PIR sensor connected to GPIO-12 as "Switch input - Switch" and it works as expected, so when motion is detected the GPIO-12 is High and I also send the detection via MQTT, all ok it works.
I would like to trigger an alarm siren when motion is detected, so I'm thinking to use another GPIO (GPIO-16) to use as signal to send to the alarm siren.
So my idea is:
When motion is detected (so GPIO-12 High) set to High the GPIO-16 for 30 seconds also if in these 30 seconds the motion is not more detected (so also if GPIO-12 go to Low). In other words I want to hear to the siren for 30 seconds when motion is detected and also if the detection is for only 3 seconds.
Then, when motion is not more detected (so GPIO-12 Low), stop the alarm siren (so GPIO-16 got to Low).
If, after 30 seconds or more, another motion is detected (or detection is still in progress) the alarm siren should still make sound.
Use this behavior forever.
I have created this Rule:
Code: Select all
on motion#Detection=1 do
GPIO,16,1
TimerSet,1,20
Endon
On Rules#Timer=1 do
GPIO,16,0
endif
endon
Many thanks for help.