Introduction: Control Raspberry Pi GPIO Using Amazon Echo (Fauxmo)

Picture of Control Raspberry Pi GPIO Using Amazon Echo (Fauxmo)

This project covers controlling Raspberry Pi GPIO using an Amazon Echo.
It uses Fauxmo which enables the RPi to pretend as a WeMo device. Fauxmo is a Python 3 module that emulates Belkin WeMo devices for use with the Amazon Echo.

To get a confirmation of change in state for GPIO you either look at the terminal in which you will run the code or use this instructable to connect GPIO ( for this project 16-26) to an LED for visual check.

Inspired by Home Automation With Amazon Echo Voice Control by FabricateIO

Step 1: Setup and Test

Picture of Setup and Test

You will need an Amazon Echo, Raspberry Pi ( I am using a RPi 3 Model B) and copy of source code.

  1. Download a copy of the source code in your RPi 'home' (~/)
    git clone https://github.com/kanesurendra/echo-pi.git
  2. Move to source directory:
    cd echo-pi
  3. Execute the script using:
    python gpio_control.py
  4. Say to your Echo : "Alexa, discover devices"
    Each GPIO is registered as a independent device and can be controlled separately.
  5. To change a state of GPIO say : "Alexa, turn on gpio21" or "Alexa, turn off gpio21

Step 2: Summarizing ...

Picture of Summarizing ...

Although this allows you to control individual GPIO's, by experimentation found that it allows only about 9-10 devices (GPIO's) to be discovered. The Echo discovery ends in 20 secs; before the script can respond to discovery if all 26 gpio pins are included.

Hence in the above source code only the gpio16 - gpio26 are added as devices and can be controlled.
Looking for a fix or alternative ....

Comments

bvis222 (author)2017-12-08

Hi and Thanks,

I have one working and only using 3 gpio ports...I'm trying to get another rPi running with a different 3 ports but can't get Alexa to discover the ports.

Is it possible to run more than one rPi this way??? or do I need to change a setting???

thx

sanju007kalol (author)2017-11-13

hello to all,

i am try to run this file on my raspberry pi 3 but i get only 12 GPIO PIN in alexa, how to can add more GPIO PIN and is work with individual fine but if i try to make group with two GPIO PIN so alexa on and off only 1 GPIO PIN, any one tell me how to add more GPIO pin in alexa list and how to control TWO or more GPIO in one group

thnks

If you are just grouping pins you can set the state of the additional pin in the if then statement:

if state == True:
GPIO.setup(port, GPIO.OUT)
GPIO.output(port,GPIO.HIGH)

GPIO.setup(25, GPIO.OUT)
GPIO.output(25,GPIO.HIGH)

else:
GPIO.setup(port, GPIO.OUT)
GPIO.output(port,GPIO.LOW)

GPIO.setup(25, GPIO.OUT)
GPIO.output(25,GPIO.LOW)

troberts618 (author)2017-11-20

When I add a crontab entry "@reboot sudo python /home/pi/gpio-control.py", the discovery fails. Is there another way to autostart the script without using crontab?

pcook10 (author)2017-10-22

is there any way to change the names so instead of asking for 'GPIO23' you can ask for 'lights' ??

ChucheS (author)pcook102017-10-30

All i did was to change the names of the gpios in gpio-control.py:
my line for gpio_ports = ... ends like this:

'red light':21,'green light':22,'yellow light':23,'gpio24':24,'gpio25':25,'gpio26':26}
so you can see the yellow light is connected to GPIO 23, the green to GPIO 22 and the red to GPIO 21.
Then I changed the names for the triggers like this:

{"gpio15":50015,
"gpio16":50016,
"gpio17":50017,
"gpio18":50018,
"gpio19":50019,
"gpio20":50020,
"red light":50021,
"green light":50022,
"yellow light":50023,
"gpio24":50024,
"gpio25":50025,
"gpio26":50026}

i then saved the gpio-contro.py and re-ran the script.
It works like a charm for me.ATM I'm struggling to create a sequence since this kind of 'device' is not yet supported in the 'routine' section of the Alexa App (Android)

good luck

SharjeelG (author)2017-06-07

Traceback (most recent call last):

File "/home/pi/gpiocontrol.py", line 6, in <module>

from debounce_handler import debounce_handler

ImportError: No module named 'debounce_handler'

While i am trying to run the program it showing this error.

Can u help me plz?

About This Instructable

4,086views

15favorites

License:

More by surendrakane:Control Raspberry Pi GPIO Using Amazon Echo (Fauxmo)Control Raspberry Pi GPIO Using Amazon Echo (ngrok)Control LED Using Raspberry Pi GPIO
Add instructable to: