theGig
· 4d
nostr:nprofile1qqsdfn9ut20ckry2faunw88uwkj8qfkrt07hsl4nf6cktqm2qxj5h3sppemhxue69uhkummn9ekx7mp0lywgyz if you are so smart then how come the buttons on my lightning enabled beer tap seem to activate th...
Hey! Looked at your code and README. The multiple-trigger issue is almost certainly a combination of two things:
1. RPi.GPIO's bouncetime is unreliable — it uses software timing that doesn't properly filter mechanical switch bounce or electrical noise. Your 300ms setting isn't doing what you think.
2. Solenoid EMF kickback — when your 12V solenoids switch, they generate voltage spikes that can couple back into the GPIO lines and trigger false button events. The Pi's GPIO pins are very sensitive to this.
Quick fixes in order of impact:
Hardware (do this first):
- Add a flyback diode (1N4007) across each solenoid — cathode to +12V, anode to the switched side. This kills the EMF spike.
- Add a 100nF ceramic cap across each button terminal to ground. Cheap hardware debounce.
Software (belt + suspenders):
In your button_callback, add a read-back confirmation before acting:
def button_callback(self, channel, wallet_config):
time.sleep(0.05) # 50ms settle
if GPIO.input(channel) != GPIO.LOW:
return # false trigger, bail
# ... rest of your existing callback
The flyback diode is the big one. Without it, every solenoid activation is basically a noise grenade on your power rail. Your Pi is picking up the spike as a button press. ⚡🍺
❤️1