I could get rid of these spikes by adding resistors and capacitors, but I would prefer to solve this in my flow ...
I (ab)used the debouncer of the RPI-GPIO node to get rid of these glitches:
Now everything seems to be working fine ...
However I have a few questions about this setup:
# add rising edge detection on a channel, ignoring further edges for 200ms for switch bounce handling
GPIO.add_event_detect(channel, GPIO.RISING, callback=my_callback, bouncetime=200)
--
http://nodered.org
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
To view this discussion on the web, visit https://groups.google.com/d/msgid/node-red/593114c1-5e76-4735-ae60-27f51aa8c6c3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
http://nodered.org
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
To view this discussion on the web, visit https://groups.google.com/d/msgid/node-red/1cc79a9c-4263-4ca4-bb6d-9ada906ca429%40googlegroups.com.
--
http://nodered.org
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
To view this discussion on the web, visit https://groups.google.com/d/msgid/node-red/ded694c9-2695-4336-bdd0-ffcd3127dfb3%40googlegroups.com.
The GPIO pins have been designed this way, to assure that a signal source - whose signal we are measuring - is not loaded heavily (by keeping the current low). This way the Raspberry can measure signals without consuming lots of energy.
Since the Raspberry has a very high impedance, a small distortion will result quickly in a rather high noise level. As a result I ended up reading a very noise signal. I deactivated the Raspberry's internal pullup resistor, and added a an external 10 kOhm resistor (between GPIO pin and 3,3V). The signal was cleaner, but there was still too much noise (1 division = 1 Volt):
As soon as some threshold voltage is exceeded, the GPIO pin will consider (incorrectly) the noise as a digital 1:
As a result, the RPI-GPIO input node injected an horrible amount of messages into my flow: the flow editor freezed since it could not handle all the information ;-(
The node's debouncing functionality is added to get rid of a short series of spikes, not for an endless spike train... In this case the debouncer only reduces (drastically) the amount of messages. When the debounce interval is N msecs, all messages within that interval will not be injected in the flow. But at the end of the interval, a message will be generated if the GPIO pin still has the same value (compared to the value at the start of the interval). Since we have lots of noise, chances are pretty high that we receive still lots of messages (but with a plural of N msecs in between). I assume that explains why I got spikes at rather regular intervals.
At the end I have added a low-pass RC filter, that filters away all high frequencies:
P.S. I also tried it first without the resistor of 270 ohm, however then it doesn't detect anymore when the door is opened and closed very fast ...
Now at least I had a clean signal !! And my flow started running like nothing happened ...
Bart Butenaers