I need to detect the presence of a square wave with a frequency of about 1 kHz on the GPIO input.
If such a square wave appears, I want to send SendToHTTP to Domoticz and also if it disappears, send SendToHTTP to Domoticz as well.
Of course, I can assemble an integrating circuit on an operational amplifier, but I don't want to solder.
Is it possible to do it somehow using rules using e.g. "input switch" by setting the "De-bounce" parameter appropriately?
Any idea?
Detect presence of square wave
Moderators: grovkillen, Stuntteam, TD-er
-
- Normal user
- Posts: 534
- Joined: 07 Jun 2018, 06:47
- Location: Gdynia/Poland
Re: Detect presence of square wave
You could perhaps use the pulsecount plugin and then look at the counted frequency.
With the Interval of such task set to 1 sec, the "count" will be very close to a real frequency counter.
Preferrably use an ESP32 for this as the pulsecount is then done in hardware, not in software as on the ESP8266.
With the Interval of such task set to 1 sec, the "count" will be very close to a real frequency counter.
Preferrably use an ESP32 for this as the pulsecount is then done in hardware, not in software as on the ESP8266.
-
- Normal user
- Posts: 534
- Joined: 07 Jun 2018, 06:47
- Location: Gdynia/Poland
Re: Detect presence of square wave
Or to use a capacitor connected to GPIO and GND. If ESP32/8266 has Schottky like characteristc.
Does it?
Does it?
Re: Detect presence of square wave
I'm not sure what you'd expect from adding a capacitor?
Do you expect it to act like a simple DA converter or high-pass filter?
Do you expect it to act like a simple DA converter or high-pass filter?
-
- Normal user
- Posts: 534
- Joined: 07 Jun 2018, 06:47
- Location: Gdynia/Poland
Re: Detect presence of square wave
Yes.
This square wave is fed to the GPIO input through an optocoupler because it has 24V and comes from a completely different device with its own power supply. Hence the capacitor eg 680 nF "integrates" the square wave to DC voltage. Approximately, of course.
The delay introduced by such a system is in this case irrelevant to me. If it's even 2-3 seconds, it's OK.
Only for it to work properly, the input must have a voltage hysteresis characteristic - like Schottky gates.
I can't find an answer anywhere whether GPIO configured as an input has such characteristics.
I think so. But I couldn't find confirmation.
This square wave is fed to the GPIO input through an optocoupler because it has 24V and comes from a completely different device with its own power supply. Hence the capacitor eg 680 nF "integrates" the square wave to DC voltage. Approximately, of course.
The delay introduced by such a system is in this case irrelevant to me. If it's even 2-3 seconds, it's OK.
Only for it to work properly, the input must have a voltage hysteresis characteristic - like Schottky gates.
I can't find an answer anywhere whether GPIO configured as an input has such characteristics.
I think so. But I couldn't find confirmation.
Re: Detect presence of square wave
Why not simply use a capacitor in series with the signal?
This should block DC, but will transfer AC signals.
Then just let this charge a capacitor, which does have a resistor over it to eventually discharge it when it doesn't get charged.
So just something like a small transistor (or FET) to charge the capacitor upto 3V3 via some resistor and a larger resistor value over this capacitor to discharge it
With a ratio of 1:10 you will still get over the logic '1' level of the ESP.
And the series capacitor on the input will filter out any DC signal.
This should block DC, but will transfer AC signals.
Then just let this charge a capacitor, which does have a resistor over it to eventually discharge it when it doesn't get charged.
So just something like a small transistor (or FET) to charge the capacitor upto 3V3 via some resistor and a larger resistor value over this capacitor to discharge it
With a ratio of 1:10 you will still get over the logic '1' level of the ESP.
And the series capacitor on the input will filter out any DC signal.
-
- Normal user
- Posts: 534
- Joined: 07 Jun 2018, 06:47
- Location: Gdynia/Poland
Re: Detect presence of square wave
THX. Will try.
Who is online
Users browsing this forum: No registered users and 0 guests