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.
- Download a copy of the source code in your RPi 'home' (~/)
git clone https://github.com/kanesurendra/echo-pi.git - Move to source directory:
cd echo-pi - Execute the script using:
python gpio_control.py - Say to your Echo : "Alexa, discover devices"
Each GPIO is registered as a independent device and can be controlled separately. - 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 ....

Participated in the
Microcontroller Contest 2017
44 Comments
1 year ago
My version of fauxmo no longer works. So, I thought I'd try yours. However, this link doesn't seem to exist: https://github.com/kanesurendra/echo-pi.git.
I searched github for kanesurendra aand echo-pi and came up empty. Any help would be appreciated.
5 years 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?
Reply 5 years ago
Having same problem but in English... Did you found a solution?
Reply 5 years ago
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.
Reply 5 years ago
Maybe the new Alexa plus is the problem? WhichAlexa do you use?
Reply 5 years ago
I am having the same issues I have an echo dot gen 2
Reply 4 years ago
This is critical:
Your raspberry pi MUST BE ON THE SAME WiFi network as the Alexa devices (Amazon Echo, Amazon Echo Dot or Amazon Echo Plus)!!! If you raspberry pi is on a different subnet then your Echo devices Alexa will NOT discover them. Also use a static IP address on your raspberry pi. Because if your raspberry pi’s IP address changes AFTER Alexa has discovered your fauxmo Wemo devices, Alexa will no longer work. If your raspberry pi IP address changes you will have to have Delete the fauxmo devices from the Alexa App and redo the discovery process again
Hint:
When trying to discover your fauxmo devices place fauxmo.py into DEBUG mode so you can see the fauxmo print statements. WAIT until you see “searching for device” printed to the screen BEFORE you tell Alexa to discover devices. The fauxmo.py python3 script has to enter a polling state so it can respond to the discovery process
Reply 3 years ago
how do you place the file in debug mode
Reply 5 years ago
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...
Reply 5 years ago
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.
Reply 5 years ago
which echo are you using? I had a problem using the amazon echo, but I tried my sons amazon dot and it worked flawless. maybe you could try?
6 years ago
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?
Reply 4 years ago
Sounds like /home/pi directory does not have debounce_handler.py python3 script is missing.
Your gpiocontrol.py script on line 6 has the following python3 statement:
from debounce_handler import debounce_handler
this imports debounce_handler.py python3 code
You will need this code to stop Alexa from making multiple calls to device_handler when you Ask Alexa to control your fauxmo Wemo device.
5 years ago
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
Reply 4 years ago
each raspberry pi should be using a static IP address, so you can use the same port numbers.
The way fauxmo.py python3 script works, the fauxmo.py uses the following as the TCP port number
(Static IP Address of your raspberry pi):51000 for one “named device 1”
(Static IP Address of your raspberry pi):51001 for one “named device 2”
And so on
So if my raspberry pi’s static IP address is 192.168.1.30
So, Then each “named device 1” would be at 192.168.1.30:51000
and
“named device 2” would be at 192.168.1.30:51001
Again, as long as your raspberry pi have unique static IP addresses then you can use the same port numbers for each raspberry pi.
Of course each raspberry pi will HAVE different IP addresses otherwise you would not be able to talk to each raspberry pi over your Ethernet. You DHCP server (or your router) does this for you automatically.
To assign a static IP address to your raspberry pi, you will need to access your router’s LAN setup and reserve an IP address for the MAC address of your raspberry pi. To find the MAC address of your raspberry pi do the following at a command prompt “ifconfig”
Look at the output from ifconfig and either on “eth0” or “wlan0” you will see an address assigned 192.168.x.xx then look for “ether” string. The MAC or “ether” is in the following format for raspberry pi:
b8:27:eb:xx:xx:xx where xx:xx:xx is different for each raspberry pi
5 years ago
my Alexa is not finding any devices? any help would be appreceiated
Reply 4 years ago
This is critical:
Your raspberry pi MUST BE ON THE SAME WiFi network as the Alexa devices (Amazon Echo, Amazon Echo Dot or Amazon Echo Plus)!!! If you raspberry pi is on a different subnet then your Echo devices Alexa will NOT discover them. Also use a static IP address on your raspberry pi. Because if your raspberry pi’s IP address changes AFTER Alexa has discovered your fauxmo Wemo devices, Alexa will no longer work. If your raspberry pi IP address changes you will have to have Delete the fauxmo devices from the Alexa App and redo the discovery process again
Hint:
When trying to discover your fauxmo devices place fauxmo.py into DEBUG mode so you can see the fauxmo print statements. WAIT until you see “searching for device” printed to the screen BEFORE you tell Alexa to discover devices. The fauxmo.py python3 script has to enter a polling state so it can respond to the discovery process!
5 years ago
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?
Reply 5 years ago
boot your pi as normal, then from the directory you have it saved run this:
nohup python gpio-control.py > /dev/null 2>&1&
then it will run in the background and after you close your terminal
Reply 5 years ago
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.