LowPowerLab Forum

Software support => Coding questions => Topic started by: Lukapple on January 30, 2020, 04:32:29 PM

Title: Digital input pin - measuring frequency?
Post by: Lukapple on January 30, 2020, 04:32:29 PM
Hi,
can anyone recommend a simple lightweight library for measuring frequency of digital input pin signal?

I want to do a simple garage door status detector. Garage door opener has a contact, which is:
- open when door is closed,
- 0.5s open and 0.5s closed (repeating signal) when door is closing,
- 1s open and 1s closed (repeating signal) when door is opening and
- closed contact when door is open

I connected that contact to Moteino (Digital pin and GND pin) and now I want to detect the state of the door.
Title: Re: Digital input pin - measuring frequency?
Post by: TomWS on February 01, 2020, 06:50:03 PM
There is an Arduino library called FreqCounter that I've used for moisture sensors, but I think the sensing frequency range is higher than what you're looking for.  You might be able to create a couple of Bounce2 objects (using Bounce2 library), using the same pin as the input, but different bounce characteristics to filter out each type of signal.
Title: Re: Digital input pin - measuring frequency?
Post by: Lukapple on February 03, 2020, 03:57:03 AM
Thanks for the suggestion Tom. I'll try with to solve that problem with Bounce lib.