Thank you for your donation!


Cloudsmith graciously provides open-source package management and distribution for our project.


Solved: Debugging/debouncing GPIO buttons... (false triggers)
#11
@challenge

I had similar issue to yours, but I overcome this by changing the "logic" of triggering actions by momentary switches.

I changed the wiring to:
+3.3V (GPIO pin 1) -> momentary switch -> GPIO input pin defined on Moode GPIO setup page.

To use this kind of wiring you need to adjust mentioned script to initialize input GPIO pins to low logic (zero), by changing all the "GPIO.setup" lines in script /var/www/daemon/gpio_buttons.py

By default all input GPIO pins configured on Moode GPIO setup page are set to high logic state.
This is realized by lines:
Code:
GPIO.setup(sw_1_pin, GPIO.IN, pull_up_down=GPIO.PUD_UP)

What needs to be done for my wiring is just to change them all buy this simple command being logged via ssh as pi user:

Code:
sudo sed -i s/pull_up_down=GPIO.PUD_UP/pull_up_down=GPIO.PUD_DOWN/g /var/www/daemon/gpio_buttons.py

After this modification you can even reduce debounce paramter to 150ms from default 1000ms (1s).

PS This is for RPi 3B+ and I found in documentation, that each GIPO pin has internal pull up / pull down resistors, so you don't need to use additional external resistors.
Details can be found here: Raspberry Pi hardware

Here is my pins configuration:
Code:
- all GPIO settings are in moode-sqlite3.db located in /var/local/www/db and must be defined via GUI
- gpio settings:
id    pin    enabled    command    param    value
1    26    1    mpc,play        
2    6    1    mpc,stop        
3    5    1    /var/www/vol.sh,mute        
4    22    1    /var/www/vol.sh,up,2        
5    27    1    /var/www/vol.sh,dn,2        
6    24    1    mpc,next        
7    12    1    mpc,prev        
8    13    1    /var/local/www/commandw/restart.sh,poweroff        
99                bounce_time    150
----
Cheers!

Marek.Marakesh

Internet HiFi Radio streams enthusiast:
- RPi 3B+ with HiFiBerry Digi2-Pro
- RPi 3B+ with HiFiBerry Amp2

Reply


Messages In This Thread
RE: Debugging/debouncing GPIO buttons... (false triggers) - by marek.marakesh - 11-22-2022, 09:36 PM

Forum Jump: