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
Steps:
Software
- Install Raspbian Raspberry Pi OS – Raspberry Pi
- Hook up pi to a monitor, keyboard and mouse and connect to your wifi: Raspberry Pi Documentation - Configuration
- Enable SSH: Raspberry Pi Documentation - Remote access 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 GitHub - jessiewbailey/fauxmo: Emulated Belkin WeMo devices that work with the Amazon Echo 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.
Hardware
- 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).
-
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).
Part list:
- 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)
- Receptacle
- 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
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: Using the Raspberry Pi to control AC electric power | TechNotes