alexa-pi / AlexaPi

Alexa client for all your devices! # No active development. PRs welcome # consider https://github.com/respeaker/avs instead
MIT License
1.33k stars 396 forks source link

How to trigger the top 3 LEDs of respeaker 2mic hat when Alexa listens and responds? #375

Open jabulonboaz opened 6 years ago

jabulonboaz commented 6 years ago

Your OS (including version) where you are running AlexaPi:

Raspbian Jessie lite

Your hardware platform and model you are running on: Pi zero w and pi3 vb

Python release (python2 --version):

Do not know

Description of problem: How to trigger the top 3 leds of respeaker 2mic hat on a RaspberryPi zero w with an AlexaPi build when Alexa listens and responds?

Expected: Control the respeaker 2 mic hat hat 3 rgb leds when Alexa listens and talks

Problem-relevant config.yaml entries: GPIO config on rspberry pi

Additional info: Does anyone know how the top 3 leds of respeaker 2mic hat be triggered when Alexa listens and talks on a RaspberryPi zero w with an AlexaPi build please?

renekliment commented 6 years ago

If the LEDs are connected directly to RPi's GPIO pins, you can use the existing raspberrypi device platform and set that up in the configuration file, it's pretty straightforward.

If you need something more complex, feel free to write your own _device platform file_.

jabulonboaz commented 6 years ago

@renekliment they are not unfortunately they are controlled via SPI that I only now started to read bout here https://github.com/tinue/APA102_Pi This is from the Respeaker product description: http://wiki.seeed.cc/Respeaker_2_Mics_Pi_HAT/ ‘RGB LED: 3 APA102 RGB LEDs, connected to SPI interface I did try to change the GPIO settings in the AlexaPi relevant raspberry pi LED section at “config .yaml” and I did successfully enabled the Respeaker button on GPIO 17 for Alexa triggering by pressing it in addition to the hotword activation but when I change the LED settings by inserting GPIO 10 that is the respeaker pin for its rgb leds nothing happens.

AlexaPi config.yaml alterations: sudo nano /etc/opt/AlexaPi/config.yaml

voice_confirm: true

raspberrypi:

GPIO Pin with button connected

button: 17 # GPIO 17 corresponds to the respeaker 2mic hat push button 
# GPIO Pin for the playback/activity light
plb_light: 10 # Read below 
# GPIO Pin for the recording light
rec_light: 10 # GPIO 10 is the data pin of the Respeaker 2mic Hat  3 LEDs also tried 11 that’s the CLK of these LEDs

I am just an armature with an engineering background trying to learn by googling and reading the great work that yourself and others are putting together I am not a coder or a developer I am afraid . Any pointers, any URLs or any tips you can recommend I am happy to follow.

Other questions relevant to config.yaml of AlexaPi: Another thing I like to do is to be able to control with buttoyyns connected to GPIO pins the volume of Alsa mixer again any tips and online material you can point too I would be very grateful. Also is it possible to enable a voice trigger shutdown ? I saw a relevant command in config.yaml but I do not know what to do to enable it if this is what it does.

Command to run during a clean shutdown of AlexaPi

shutdown: "" Finally I am trying to understand how to setup custome wakewords or hotword using Snowboy so any pointers on how exactly to modify what part of the AlexaPi code to do this I would appreciate a lot too. Thank you in advance

jabulonboaz commented 6 years ago

after playing with the SPI Alexa stooped working Feb 11 17:17:38 raspberrypi python[470]: ALSA lib pcm_dmix.c:990:(snd_pcm_dmix_open) The dmix plugin supports only playback stream Feb 11 17:17:39 raspberrypi python[470]: ALSA lib pcm_dsnoop.c:556:(snd_pcm_dsnoop_open) The dsnoop plugin supports only capture stream Feb 11 17:20:06 raspberrypi python[470]: INFO: Checking Internet Connection ... Feb 11 17:20:07 raspberrypi python[470]: INFO: Connection OK Feb 11 17:20:07 raspberrypi python[470]: INFO: AVS token: Requesting a new one Feb 11 17:20:07 raspberrypi python[470]: INFO: AVS token: Obtained successfully Feb 11 17:20:17 raspberrypi python[470]: INFO: Triggered: pocketsphinx Feb 11 17:20:21 raspberrypi python[470]: INFO: (process_response Error) Status Code: 403 Feb 11 17:20:23 raspberrypi python[470]: INFO: Triggered: pocketsphinx Feb 11 17:20:31 raspberrypi python[470]: INFO: (process_response Error) Status Code: 403

any ideas ?

EmerickH commented 6 years ago

You can use event_commands in the config to launch your own commands: https://github.com/alexa-pi/AlexaPi/blob/master/src/config.template.yaml#L80