De-Bounce for reed switch?

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
TommySharp
Normal user
Posts: 19
Joined: 20 Oct 2017, 14:30

De-Bounce for reed switch?

#1 Post by TommySharp » 22 Aug 2018, 12:31

I have a reed switch connected and when my garage door closes is see a quick CLOSED, OPENED, CLOSED in quick succession.
Does anyone have any pointers on how I would ignore any updates within 1 second of the first one?
I think the term is a "de bounce"?
2018-08-22_222906.png
2018-08-22_222906.png (25.24 KiB) Viewed 5568 times

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: De-Bounce for reed switch?

#2 Post by grovkillen » 22 Aug 2018, 13:15

You could use rules for that... on change wait for 1-2 seconds... check again. If the value is still OPEN report open. Etc.

But that might not be a good solution for you? Please report back if you have tried it and it's not working.
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 :idea: :idea: :idea:

TommySharp
Normal user
Posts: 19
Joined: 20 Oct 2017, 14:30

Re: De-Bounce for reed switch?

#3 Post by TommySharp » 12 Sep 2018, 02:39

Would be great to be able to do this without rules....
Surely this is a common issue with reed switches and a fix could be baked in?

I've never written a rule though so if you could help me with a working example I could give it a try.....

kenkoknz
Normal user
Posts: 64
Joined: 03 Jul 2018, 23:46
Location: New Zealand

Re: De-Bounce for reed switch?

#4 Post by kenkoknz » 12 Sep 2018, 04:21

Exactly as what @grovkillen said,
I have not tested it but maybe along the lines of (have to press it longer than 1sec, I am not sure if TimerSet works for 0.5):

On ReedSwitch#Open do
TimerSet,1,1
EndOn

On Rules#Timer=1 do
If [ReedSwitch#Open]=0 // 0 or 1 depends on what state you are looking for.
// .....whatever
EndIf
EndOn

Check out great tutorial on rules n give it a go.

Ken

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: De-Bounce for reed switch?

#5 Post by grovkillen » 12 Sep 2018, 06:24

kenkoknz wrote: 12 Sep 2018, 04:21 Exactly as what @grovkillen said,
I have not tested it but maybe along the lines of (have to press it longer than 1sec, I am not sure if TimerSet works for 0.5):

On ReedSwitch#Open do
TimerSet,1,1
EndOn

On Rules#Timer=1 do
If [ReedSwitch#Open]=0 // 0 or 1 depends on what state you are looking for.
// .....whatever
EndIf
EndOn

Check out great tutorial on rules n give it a go.

Ken
Thanks for stepping in! :) I love how the community grow and how we start to take care of each other.
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 :idea: :idea: :idea:

TD-er
Core team member
Posts: 8644
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: De-Bounce for reed switch?

#6 Post by TD-er » 12 Sep 2018, 21:12

When I take on the GPIO issues, one of the things I want to do is to merge functionality of P001_switch and P003_pulsecount.
That last one already has some code to filter de-bounce effects.

TommySharp
Normal user
Posts: 19
Joined: 20 Oct 2017, 14:30

Re: De-Bounce for reed switch?

#7 Post by TommySharp » 13 Sep 2018, 22:53

I think doing this with a rule is actually a little more complicated than I can manage right now.
Will have to wait till debouncing is built in for reed switches...

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 23 guests