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
- Install Raspbian https://www.raspberrypi.org/downloads/raspbian/
- Hook up pi to a monitor, keyboard and mouse and connect to your wifi: https://www.raspberrypi.org/documentation/configuration/wireless/wireless-cli.md
- Enable SSH: https://www.raspberrypi.org/documentation/remote-access/ssh/ and disconnect pi from everything but power, complete the remaining steps over SSH.
- Install the LAMP stack (https://www.raspberrypi.org/learning/lamp-web-server-with-wordpress/)
- Copy PHP code and scripts from below, making sure the PHP code points to the relevant scripts.
- Add the apache user to the sudoers list with no password needed to run python (will add instructions later)
- Put .py scripts in ~/home/pi/Python/ as needed. Perform a $chmod 777 <script_name> on each script.
- 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.
- Follow instructions on https://github.com/jessiewbailey/fauxmo to get the wemo emulator running and communicating with your Echo.
- 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.
- 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).
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.
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.
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).
- A relay module with sufficient current rating for your intended use
- High current wires capable of handling the needed current (I used 16 gauge speaker wire)
- Female to female wires for relay and raspberry pi pins
- Raspberry Pi
- MicroSD and means to program it (laptop with SD slot or USB adapter)
- Wood - I used about 20" of .5" x 3.7" white oak from Home Depot
- Micro USB cable and USB wall adapter for powering the pi
- 15A rated inlet and cable (I don’t recall where I got mine).
- Machine screws and nuts for holding unit together