Control Raspberry Pi GPIO Using Amazon Echo (Fauxmo)


Introduction: 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

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
  2. Move to source directory:
    cd echo-pi
  3. Execute the script using:
  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 ...

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 ....



  • Creative Misuse Contest

    Creative Misuse Contest
  • Water Contest

    Water Contest
  • Clocks Contest

    Clocks Contest

31 Discussions

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

2 replies

boot your pi as normal, then from the directory you have it saved run this:
nohup python > /dev/null 2>&1&
then it will run in the background and after you close your terminal

I'm having the same problem. Adding the cron with @reboot directive or adding to rc.local doesn't launch the script for some reason. Logging in when the device boots up to run a command is not the same functionality as a @reboot directive in cron.

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

3 replies

Once the you find the devices you can change the name of the device in the alexa app. This is what I did.

This is what I did. There's no point in changing the script since you can rename them once they are discovered.

All i did was to change the names of the gpios in
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:

"red light":50021,
"green light":50022,
"yellow light":50023,

i then saved the 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

I have added a group in the alexa app containing four of the gpio pins. When I ask alexa to turn on the group of devices, only one device turns on. is this a limitation of this script?

1 reply

I have the same issue, although I get random number of pins responding. Sometimes only one, sometimes zero, sometimes two.


Question 26 days ago

When I try to connect this to a power relay board the modules stay on always. Is there a way to fix this? I have it connected to the VCC of the pi, with a jumper on the VCC and JD-VCC of the relay board. If I give the relay its own power source will that allow the voice commands to control the relay through the gpio commands?

1 more answer

If you supply the relay board with its own power, then you will still wire up vcc, gnd, and each relay control pin to the raspberry pi as normal. The problem is that the pi doesn't have enough power to run itself, the control circuit of the relay board, and the relays itself. Disconnect the jumper and connect a separate 5V power supply to the JD-VCC and GND pins to the side of the main bank of pins.

I'm trying to add a small simple script to this code where as I only want one of the relays to switch on for one second.
this is my script:
import RPi.GPIO as GPIO
import time
just wondering when to put it in the code to make it work only for that particular GPIO pin.
any ideas or help would be good.

Hi, I get the folowing error:
File "/home/pi/Desktop/echo-pi-master/", line 66
print "State", state, "on ", name, "from client @", client_address, "gpio port: ",gpio_ports[str(name)]
SyntaxError: invalid syntax

how can I resolve this?


Hello, I do not have an Amazon Alexa however i currently use my RapPi as my Homebridge device so that i am able to control wifi enabled devices with my iPhone using the Home App.

I set up Fauxmo on the same RapPi and got it running however the Fauxmo/Wemo device doesn't show up in the apple home app.

Is it possible to get these two applications running together? I have a feeling there is an issue with using the same IP address. Is it possible to change the IP address the Fauxmo Application uses?


6 months ago

I installed it, It runs with no errors, but Alexa does not find any device. I am in Germany, my Alexa speaks German. Is there a problem with this?

PI Alexa.JPG
5 replies

Having same problem but in English... Did you found a solution?

not yet. I tried something. I wrote the IP:Port in my browser - an the raspeberry reacted. So I am sure, the script is running. But Alexa still cant find the devices from raspberry. But it finds the Hue-Lamp from Philips.

Maybe the new Alexa plus is the problem? WhichAlexa do you use?

Hey there, i also have that problem... i'm using the V2 Medium sized Alexa.
My pi is also reacting when i try to contact it via browser. Still Alexa can't find the device...

I ended up fixing mine, but I am unsure exactly how; however, I narrowed down a couple things I did.

A) I manually restarted the network

B) Made sure the network was given more IP address

1) I actually figure it was this one considering it only had 32 IPs that could be assigned, and, as such, my entire family of 7 easily dominated the network with all of their devices.