Tasmota: Counter debounce

Created on 10 Jun 2017  路  13Comments  路  Source: arendst/Tasmota

Hi, if i configure debounce for counter let say 50 or 100,
it works ok, when my gas meter is fast enough. but when the consumption is super low, magnet can close the contact for half second and even for one second (slow rolling), or even stop at "closed" state. in this case every such event is treated AS TWO events - first when the proximity sensor closes, and the second when it opens.
making debounce too high is not an option - it can miss two events in this case.

can you build a counter option to treat only CLOSING as event (not both, closing and opening).

thanks

stale

All 13 comments

You'll have to find some kind of debounce on your magnet as I'm already using only the falling edge of the signal as interrupt. I have no means to select another option.

Thanks for the explanation,
anyway - the counter right now increases on both changes - from DOWN to UP and from UP to DOWN.
why not to make this option selectable? e.g. UP only, to calculate only changes from down to UP,

I can confirm the issue.
I try to use TCRT5000 - module like this https://www.aliexpress.com/item/TCRT5000-Tracking-Module-Tracker-Infrared-Reflective-Sensor-For-Arduino-Robot-Smart-Car/32408909714.html and my counter counts always twice.

P.S. not always, only if my electricity meter rotates slower then X. if i turn on eg. water boiler it rotate faster and counter increments by 1.

@arendst any chance you can look at this option?

@off14 try to fiddle around with the counter interrupt routine in file xsns_counter.ino at line 81:

attachInterrupt(pin[GPIO_CNTR1 +i], counter_callbacks[i], FALLING);

Change FALLING to another nice Arduino supported value and experiment.

Make sure your counter input is ESP8266 compatible (3V3 NOT 5V).

my counter is a reed switch between GPIO14 and GND (magnetic)

hall sensor is another option - but will experiment later, not works perfectly with 3.3V

I think i have fixed my issue with a hardware capacitor debouncing.

do i need any resistor (pullup or pull down) if i use standard GPIO14 ? and connect it to ground via REED switch
PS i've seen pullup necessary for re-using tx/rx pins for toggle switch

I have a similar problem with a sensor. On my water meter I measure the reflection. If the water meter stops at the wrong position the sensor goes mad: it keeps pulsing like mad. Now I would like to ignore the pulses if they are not X msec apart. With a classic debounce option set to 1000ms I will get a incorrectly measured pulse every second.

@neographikal
I had this problem too with 5V

now with 3.3V no Problem

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

This issue will be auto-closed because there hasn't been any activity for a few months. Feel free to open a new one if you still experience this problem.

I have still the same issue on Slow rotations on my Gasmeter with the reed contact.
On Slow Rotations it counts twice, even with debounce on 3200.

And what means Counter1n?

Its actually running on a USB adapter 550mA through a FTDI on 3.3v.

Was this page helpful?
0 / 5 - 0 ratings