I'm busy with an ESP easy project in my bathroom. I have a small LED strip (powered by GPIO 5, 3.3 volt from the NodeMCU). I want the following result: If the PIR sensor is positive, I want to have the LED strip lit-up for 1 or 2 minutes. I use a PIR sensor without delay on it (self-delay is 2 seconds frome the PIR sensor itself)
https://www.ebay.com/itm/Mini-IR-Infrar ... 2204291166
I already tried a lot of things, but it's quite annoying to configure it well!
The current ESP easy configuration:
The current Domoticz configuration:
I already have tried to set the off delay in Domoticz on 120 seconds, but because my ESP easy already gives the off status at the same time as the on status is triggered, the LED is turning into a disco light!
I also tried to control it via a Domoticz event
And it also doesn't really work (becaus I entered the value of 20.000 in the URL to open, there is a quite 'long' delay, but it's not the 40 seconds. The logic of the 'wait' command doesn't really make sense.
I think this should be
Control LED strip by PIR sensor (with timer function?)
Moderators: grovkillen, Stuntteam, TD-er
Re: Control LED strip by PIR sensor (with timer function?)
Why using Domoticz fot this task?
Simply use rules on your ESPeasy.
It works then without Domoticz.
If PIR sensor triggers, set gpio pin for your LEDs on and set Timer1 to 120sec.
And On Timer1 event set gpio pin for your LEDs off.
Or if your PIR and LEDs are on different ESPEasys, send command directly between this units - again without Domoticz.
Instead PIR trigger in the example above use event trigger from incoming command.
And then you can report state of PIR and LED to Domoticz, if you need it.
Advantage - this way it will work even if Domoticz or your controller computer crashes.
https://www.letscontrolit.com/wiki/inde ... rial_Rules
Simply use rules on your ESPeasy.
It works then without Domoticz.
If PIR sensor triggers, set gpio pin for your LEDs on and set Timer1 to 120sec.
And On Timer1 event set gpio pin for your LEDs off.
Or if your PIR and LEDs are on different ESPEasys, send command directly between this units - again without Domoticz.
Instead PIR trigger in the example above use event trigger from incoming command.
And then you can report state of PIR and LED to Domoticz, if you need it.
Advantage - this way it will work even if Domoticz or your controller computer crashes.
https://www.letscontrolit.com/wiki/inde ... rial_Rules
Re: Control LED strip by PIR sensor (with timer function?)
What you actually want in this kind of setup is: When PIR sees movement light up the LED. When it hasn't seen movement for 90 sec, switch the LED off. Right?kimot wrote: ↑25 Jan 2018, 10:11 Why using Domoticz fot this task?
Simply use rules on your ESPeasy.
It works then without Domoticz.
If PIR sensor triggers, set gpio pin for your LEDs on and set Timer1 to 120sec.
And On Timer1 event set gpio pin for your LEDs off.
Or if your PIR and LEDs are on different ESPEasys, send command directly between this units - again without Domoticz.
Instead PIR trigger in the example above use event trigger from incoming command.
And then you can report state of PIR and LED to Domoticz, if you need it.
Advantage - this way it will work even if Domoticz or your controller computer crashes.
https://www.letscontrolit.com/wiki/inde ... rial_Rules
I agree, this need to be done in rules, not Domoticz (its actually not possible). Activate rules under the advanced tab. Then write a rule with a timer. Setup the PIR as switch input, named PIR.
a rule for that will look something like that :
Code: Select all
On PIR#switch=1 do
gpio,5,1
timerset,1,90
Endon
On Rules#Timer=1 do
gpio,5,0
Endon
Domoticz on Raspi 2 -- 14 ESP units (hacked Sonoff,NodeMCUs, Wemos, self-built units) running with RC140- Mega 2.0.0 dev8
Re: Control LED strip by PIR sensor (with timer function?)
Thank you very much for your help! I'm not a hardcore programmer, so it's all quite difficult for me, sorry for that!
I tried to setup the rule with the same rule as you said above, and I see in the logging the following:
I see that the event is triggered, but I don't see the action (set GPIO 5 to 1, or to 1000, I've also tried that...)
Note: the PIR sensor is really quick in the off-state, so after 1 or 2 seconds it already give the status '0' .
I also tried only the above script
But it also doesn't give any results.
Edit: I finally got it, with the following code.
The thing I forgot was the 'value' from device, to set it as 'switch' ! See the picture here:
Thanks everyone!
I tried to setup the rule with the same rule as you said above, and I see in the logging the following:
I see that the event is triggered, but I don't see the action (set GPIO 5 to 1, or to 1000, I've also tried that...)
Note: the PIR sensor is really quick in the off-state, so after 1 or 2 seconds it already give the status '0' .
I also tried only the above script
Code: Select all
On PIR#switch=1 do
gpio,5,1
timerset,1,90
Endon
Edit: I finally got it, with the following code.
Code: Select all
On PIR#switch=1 do
PWM,5,1000,200
timerset,1,90
Endon
On Rules#Timer=1 do
PWM,5,0,200
Endon
Thanks everyone!
- grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
- Contact:
Re: Control LED strip by PIR sensor (with timer function?)
As you see in the log you have named both the device and value "PIR" so your rule should be :
The log show all the events that is triggering.
Edit : you beat me to it!
Code: Select all
On PIR#PIR=1 do
gpio,5,1
timerset,1,90
Endon
Edit : you beat me to it!
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you
Who is online
Users browsing this forum: No registered users and 80 guests