Web Controlled 8-Channel Powerstrip
Greetings, fellow Raspberry Pi enthusiasts. We are about to create a multi-purpose gadget that is sure to impress! My primary reason for building this to to control my Christmas lights, but that is only one of many possible uses. Basically you can plug in up to 8 appliance and turn them on and off independantly from your smart phone! If you want to setup port-forwarding on your wireless router, you can control your appliances from anywhere in the world. (Although why you would want to turn on your blender from over-seas is a bit of a mystery.) Please leave me a comment letting me know how you use your Web Controlled Powerstrip!
Before we get started, I want to give credit where credit is due: TheFreeElectron wrote an excellent instructable on controlling the Raspberry Pi GPIO pins from a web-browser. In fact, in-order to complete this instructable, you will need to follow almost all of the steps from his instructable including using his awesome web application for controlling your power-strip.
Secondly a reminder that working with mains power can be extremely dangerous. Please be very careful. Those of us that have had the experience of touching a live 120 volt wire do not EVER want to repeat the experience.
Assuming you already have your raspberry pi with the adapter and SD card, you should be able to round up the rest of the ingredients with $40-$50 dollars.
Here’s what you’re gonna need for this project:
- Raspberry Pi with SD Card
- Micro USB Power supply (Make sure your power supply can supply a full 1 amp)
- Project Box – Available at you local Target ($14.99) – Hurry these are seasonal!
- 8-Channel 5V Relay board – EBay (About $10 shipped, I found mine here.)
- 4 (qty) 15-Amp Power Receptacles (Lowe’s or Home-Depot, get the cheap ones about 80 cents each)
- 18AWG Solid Hookup Wire (3 colors) – Radio Shack (About $8.50)
- Short length of 14-Gauge wire. (Only need about 15 inches of white, I found some scrap)
- Large wire-nuts (Red or bigger)
- Colored jumper wires – Female to Female buy them on EBay here.
- Power cord (I used an old computer power cord)
- Scrap wood pieces
- Double Stik tape
- 1/4″ wood screws
- Optional (but handy): A female end of an extension cord or broken holiday-light set.
- Trim or plunge-type router with 1/8″ straight cutting bit.
- Wire strippers
- Drill & drill bits (various sizes)
- Screwdrivers (various sizes)
- Multi-meter (for testing circuitry)
- Utility knife
Step 1: A Faceplate to be Proud of
We’ll start by modifying our project box to expose the face of our power receptacles. Take your time on this step, you want it to look nice since you’re going to be impressing all of your friends with it.
We will use a spare wall plate as your template to draw the shapes you will be cutting out with the router.
Start by using a ruler and straight edge to draw a straight line centered across the long side.
Next locate the exact center of that line and make a center-mark.
Now lay your ruler along the line with the center-mark at the 10 cm point on your ruler. Carefully create a mark on the center line at positions 4, 8, 12, and 16 cm. We should end up with four center-points spaced 4 cm apart and centered along the line. These center-points will line up with the screw-hole of the wall plate and allow you to trace each of the large face-plate openings as shown. I also recommend drawing another reference line across the top or bottom to help make sure the wall-plate is parallel with the box edges when you trace the face holes.
Next use your router to carefully rout-out each of the 8 shapes to allow the receptacles to slide into place from the back. It may take a few tries to get them to fit nicely through the holes, but you’ll get it.
Tips: Routing MDF is messy with lots of fine dust. You may want to have someone blowing compressed air on the lid while you’re routing to keep the dust from obscuring the lines. Keep one of your receptacles near by so you can continue to check the fit and shave off the edges that are preventing the fit. Once all of the holes are cut and fit, clean up the whole mess with a damp cloth.
Step 2: Preparing the receptacles
Remove the long mounting screws from the ends of each of the receptacles.
Take a careful look at the receptacles. You’ll notice that on one side you have two silver screws for the common (white) wire and on the other side you have two gold screws for the hot (black) wires. We will be removing ONLY the tab on the gold (hot) side. Do NOT remove the tabs on the silver side.
Using a pair of needle-nose pliers carefully remove the tabs on the gold side of each of the 4 receptacles. You’ll need to grasp them securely and bend them back and forth until they break off. This step allows the top and bottom to operate independently. (you will be able to turn on one without turning on the other, thus we get 8 total channels rather than 4.)
Step 3: Wiring the receptacles
Now we will do a little wiring.
- Cut off 8 pieces of the black 18AWG wire about 15 to 20 cm long.
- Strip about 2 cm of the insulation from one end and bend into a hook as shown. Repeat for all 8 pieces.
- Hook one around each of the gold screws on the sides (clockwise) and firmly tighten down the screws to make the electrical connection and to secure them in place.
- Place each of the receptacles into place from the back of the box lid. Make sure they are all facing the same direction. (Notice in the 4th picture, all of the green grounding screws are on the same side.)
- Now carefully remove a section of white 14 gauge wire from the outer casing and cut three pieces about 8 cm each. Be sure to only score the outer casing with your utility or exacto knife so that you don’t cut into the bare wire. Any exposed bare wire presents a very dangerous hazard so we want to prevent it at all costs.
- Using the strip-guide on the back of the receptacles, strip off exactly the right amount of insulation from both ends so that you can press the wires into the holes as shown leaving none of the exposed wire still visible. (I bet some of you didn’t even know there was a strip guide on the back of those things. Kinda handy huh?) Remember the 14-gauge wire is quite stiff so you will want to get the lengths right. I put a little bend in the center so that I could make the the exact length I needed to go from one receptacle to the next.
- IMPORTANT! No white wires go into the holes marked for hot (black). (Duh right?) Basically we are chaining together the commons by putting a wire from 1-2, from 2-3, and from 3-4.
- Finally cut and strip one more piece of white 14-gauge wire about 10 cm and push it into the extra hole on the right hand receptacle closest to the green grounding screw. (This step is not shown in this picture but you’ll see it later on.) Just leave the other end hanging out for now.
Step 4: Securing the receptacles and mounting the relay board
For this step, we will need to measure and cut two pieces of wood which will serve to secure the receptacles in place and will also be used to mount the relay board. These will be 2.5 x 2.5 x 18 cm.
Before mounting the blocks into the lid, we will use one of them to create a wire-bending jig. (I should have taken a picture of this, sorry) I found it really helped keep the wires nice and neat which is important in this project because there are so many wires in a small space. Here’s how I did it. Make 8 marks along the block of wood to coincide exactly with the slots between the relays on the relay board. Then drill holes exactly 2 cm deep using a small bit about the same diameter as the 18 gauge wire. Now push the red wire into each hole and bend it square to make the shapes required for the wiring harness shown in the picture and cut them all off at the same location with the longest one roughly 16-18 cm from the bend. Before removing the wires from the jig, tie them together using wire ties (or tape or hot glue) That way when you remove the wiring harness each wire will line up with the relays.
Now strip off just the tip of each of the red wires about 5 mm. This will allow you to push them into the terminals on the relay boards without leaving exposed wire. Now secure them into the CENTER terminals on the relay board with the terminal set-screw as shown.
Next hold or clamp the blocks of wood in place in the box lid and then mark and drill (4) 1/8″ holes into the top of the lid (and into the blocks of wood) about 2 to 2.5 cm from each edge (in the corners) to receive a screw. (I used 4 of the screws I removed from the receptacle tabs. I realize these are not technically wood screws, but since I pre-drilled the holes they did the trick.) These screws and wood blocks effectively clamp the receptacles into places so they can’t move around.
Finally, using two small screws, mount the relay board to the top block using the two holes on the side opposite the terminals as shown. (The terminal side of the board will hang out suspended above the backs of the receptacles. Again please refer to the picture.)
For more detail: Web Controlled 8-Channel Powerstrip