Using respeaker button for wake

i have the respeaker 2 mic pi hat on a pi 3 b+. i would like to use the button on the hat to perform a wake up. that is to say press and release the button and rhasspy wakes up and wait for a command

This is doable easily with HermesLedControl (I use it to turn wake detection on/off with snips).
But for that, we need rhasspy publishing and listening every same snips topics on mqtt hermes. HermesLedControlis ready for rhasspy, just have to be patient on rhasspy side :wink:

I saved this as and run it and it does what you’re asking:

import RPi.GPIO as GPIO
import time
import requests


def button_callback(channel):
    url = 'http://YOUR_RHASSPY_IP_HERE:12101/api/listen-for-command'
GPIO.setup(BUTTON, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) # Set pin to be an input pin and set initial value to be pulled low (off)

GPIO.add_event_detect(BUTTON,GPIO.RISING,callback=button_callback) # Setup event on pin rising edge

message = input("Press enter to quit\n\n") # Run until someone presses enter

GPIO.cleanup() # Clean up

I based it on tutorials I found here:

and here:

Hope this helps!

PS - The only indents are these lines and I can’t figure out how to make them show up as indented here:
url = ‘

1 Like

You have “blockquoted” the code, which is meant for natural language, not for a programming language. If you remove the blockquote characters (>), select all the code and then click on the icon for “Preformatted text” (or press Ctrl+Shift+C), the code shows with the right indents.


yours is probably the “proper” method but i found a simpler one for me
follow the instruction to set up a custom external program to listen for a wake word
create a file

gpio -g wfi 17 falling
echo ‘okay rhasspy’

make it executable and add it to your profile as the external program to call
works great for me

1 Like

I get error below

Traceback (most recent call last):
  File "./", line 19, in <module>
RuntimeError: Failed to add edge detection