Amazon Echo / Web Controlled Outlets

WARNING: I am not an electrician, and working with high current is dangerous, so please don’t attempt a project of this type unless you know what you are doing - and obviously you do so at your own risk. This is just meant to document what I did, and hopefully get some feedback and improvement ideas from the community - so please feel free to tell me if I did something dangerous or stupid :slight_smile:

Steps:
Software

  1. Install Raspbian Raspberry Pi OS – Raspberry Pi
  2. Hook up pi to a monitor, keyboard and mouse and connect to your wifi: Raspberry Pi Documentation - Configuration
  3. Enable SSH: Raspberry Pi Documentation - Remote access and disconnect pi from everything but power, complete the remaining steps over SSH.
  4. Install the LAMP stack (https://www.raspberrypi.org/learning/lamp-web-server-with-wordpress/)
  5. Copy PHP code and scripts from below, making sure the PHP code points to the relevant scripts.
  6. Add the apache user to the sudoers list with no password needed to run python (will add instructions later)
  7. Put .py scripts in ~/home/pi/Python/ as needed. Perform a $chmod 777 <script_name> on each script.
  8. Put PHP code in your www root folder, for me this was /var/www/htdocs/, you will probably need to do a “$ sudo nano api.php” and paste contents into that file.
  9. Follow instructions on GitHub - jessiewbailey/fauxmo: Emulated Belkin WeMo devices that work with the Amazon Echo to get the wemo emulator running and communicating with your Echo.
  10. If you want create a webpage in the same www root folder with the links that look like “http://192.168.1.x/api.php?action=outlet1on” this will enable you to control your outlet from a webpage in addition to the Echo.

Hardware

  1. Carve out outlet tops and bottoms. In my case I used #10 machine screws and nuts to hold it together drilled to final size (the holes in the model are small enough that you could thread them with a tap if you wanted).

Outlet Bottom
Outlet Top (I need to edit this to add back in the receptacle holes).

  1. Use a hack saw or other means to remove excess metal on top and bottom of outlets (typically used to secure the receptacle to the wall, but not needed in this case). Keep one of the screws - use it later to fasten the receptacle to the oak in the center of the receptacle later.

  2. Wire and solder as shown here making sure to use a heat shrink tubing or other means to cover any exposed metal connectors. I used hot glue to secure everything down to the oak with the receptacle holes.

  3. Press excess cable into the gaps between circuit boards and other modules and sandwich everything between the two pieces of oak, making sure to look from the side to ensure none of the pins are being pressed on, Fasten together with machine screws and nuts leaving about a quarter inch clearance so as to allow airflow to the pi and not compress connections (decide before this if you want to tap the holes or just drill through).

Part list:

Source Code for WeMo emulator, basic PHP code, and python scripts for controlling pins: GitHub - jessiewbailey/fauxmo: Emulated Belkin WeMo devices that work with the Amazon Echo
Wiring: http://tech.iprock.com/?p=10030

Did you try it yet? Here are some thoughts: One thing I don’t see mentioned is modifying that receptacle. You need the kind that allows you to remove a metal tab so the two outlets can be controlled separately. If you discover that they both turn on everytime a single pin goes high, that is the problem.

Also, I would have used 14 gauge solid copper wire for those screw terminals where possible. It would be easy to permanently route this type of wire (less stuffing). Else, tin the ends of your speaker wire before connecting them to the screw terminals.

Another good idea might be an inline 8 amp fuse because your relays are rated at 10amps (put it inline with your hot wire from the 110v input.

You could also include a regulated 5 volt supply from a cell phone charger to power the pi. I don’t see how it gets power now unless you are using a wall wart. You can probably fit that right in there.

How do you connect to the pi? Do they have onboard wifi now? If not, a wifi module would be another good addition but would increase your power requirements from your regulated 5v supply.

It looks like a great project, but other than the satisfaction of building a very neat piece of kit, what are the advantages over just buying the Wemo outlet? They work with Echo right off the self.

Really neat Project! It looks very nice.

Not sure how well it would work with Echo, but I’ve made a similar project with a ESP8266-01 as the controller ($3, built in wifi, 2 GPIO, and about the size of a quarter). Mine was in a lamp, so it had to be smaller.

If you are looking for a way to power the Pi, Recom makes some very nice AC/DC converters that can be run off line voltage. That may be an option. It’s what I used in my project. They are pretty small, self contained, and have built in overcurrent and thermal protection.

Pi 3 has built in wifi and bluetooth LE.

1 Like

Wow really great feedback so far.

I have tried it and it works great. I am exploring ways to have wemo emulator run automatically after a reboot but an encountering permission issues where things in /etc/init.d/ cant run python scripts that control pinouts.

The receptacle I used did have a tab on the hot side that I removed.

It gets power from a wall wart (the gap on the top left is for the micro USB cable), and I would much preferred a compact power supply along the lines of what folks are suggesting, but didn’t have any luck finding anything compact - I will explore the referenced Recom products.

In terms of advantages over a real wemo, I’m still figuring that out :slight_smile:

  1. You could control a lot more outlets for your money if you got an 8 relay module and made a smart light strip but probably breaking even at best to control two.
  2. I don’t have a wemo, but obviously you have a much more powerful device with more potential if you built it with a pi, but one that is probably not going to work as smoothly as a wemo. I would imagine you could make more sophisticated scripts in python to control the outlets and perhaps wire in other sensors like IR sensors, ambient light detection, etc.
  3. With the emulator you can create an arbitrary number of fake wemo devices, so you could potentially leverage that to automate things beyond just your outlets with your Echo. So in my case I have a streaming webcam running on another pi, and I could conceivably tell the Echo to “turn webcam off” which would ultimately run a python script to shut down the service.