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.

<p>Made it. My preference for this project was only 4 outlets, so I used a 4 relay board and modified the web interface on my Pi. The 2 outlets on the left are always on and provide GFCI protection for the entire setup. The 2 middle and 2 right are controlled by the relay board.</p>
<p>I have an old 2U Blackbox PDU that works (last I checked ...) but it is accessed over telnet. Telnet is functional, but web-based is way cooler, so I ordered my very first Pi last night (and relays &amp; 'rainbow wire') &amp; in 30-45 days :) when it all arrives from China, I'm going to build this! </p><p>I already had the PDU (and it already has all the plugs - 8) + I have wire and a spare 110v to USB on hand, so my partslist is:</p><p>1 Pi $20.33 shipped (I went with an Orange Pi because it is supposed to be completely compatible and was way cheaper) <a href="http://www.aliexpress.com/item/Orange-Pi-PC-set-1-Orange-Pi-PC-USB-to-DC-4-0MM-1-7MM-power/32451459094.html" rel="nofollow">http://www.aliexpress.com/item/Orange-Pi-PC-set-1-...</a><br>1 Relay board $7.90 shipped <a href="http://www.ebay.com/itm/360717697832" rel="nofollow">http://www.ebay.com/itm/360717697832 </a> <br>1 Jumper wire $1.82 shipped <a href="http://www.ebay.com/itm/261971264426" rel="nofollow">http://www.ebay.com/itm/261971264426</a></p><p>So my total cost (assuming all goes well) is $30.05 - not bad!</p><p>Stay tuned!</p>
Sounds great! Good luck with the build!
<p>Hello, i am looking for some help please. I started using this tutorial a while ago. And have made a few mods on the website. BUT i was wondering if somebody could help with abit of code.</p><p>The website fully works, but if i turn a light on and either refresh the site or open it on a different device with the light still on. It shows on the page as being off &quot;WHEN RELOADED OR ON DIFFERENT BROUSER&quot; i then have to click the button twice to get it to go off.</p><p>I am wanting the site to grab the state of the lights as either on or off on the page loading after i have refreshed or opened on a different device.</p><p>HOPE SOMEBODY CAN HELP</p><p>I can provide the code i have if somebody can help me out.</p><p>Thank You</p>
Thanks for the great instructable. I had a lot of fun making this to work our Christmas lights. The only problem I'm having is that everything turns on when I start it even though the power buttons show off (red). I have to turn each one to green (which should be on) to turn the switch off. It's just backwards. It all worked fine when I just used LEDs as in the instructable you based this off. Any ideas why it's working the opposite with the relay board?
I just edited the code and basically switched high and low output and everything works great. Thanks again!
Facing same problen of active low relay board. Tried to change the code but failed. Need a little help. Can u tell me what to change in code??? Thanks in advance.
I should have read to the end of your instructable and I wouldn't have had that question.
<p>But thanks for bringing it up for those of us who had the same issue. ^^</p>
<p>The issue is that in the examples / pictures in the article the &quot;wrong&quot; relay board receptacles are used. Each relay has 3 receptacles, left one middle one and right one.</p><p>In the pictures the left and middle receptacles are used, if one uses de right one and the middle receptacles the board / Raspberry will behave exactly like the website (green for on red for off)</p><p>I personaly find this safer and more practical as by default now all outlets are in the off position by default. <br>But there is no right or wrong here.</p><p>You can check this yourself by REMOVING THE POWER to the relays / outlets (really important) only power your raspberry and use a multimeter and check the receptacles with the continuity test. (If your multi-meter doen't have a continuity test, just put it on one of the resistance settings.)<br><br>Did I mention to remove the main power first :D ?<br><br>By the way Thanks <a href="http://www.instructables.com/member/rleddington/" rel="nofollow">rleddington </a>for writing this article I found it verry usefull !<a href="http://www.instructables.com/member/rleddington/" rel="nofollow"><br></a></p>
<p>This worked out great, thanks! I built mine together with a temperature/humidity sensor to control my freezer chest for beer fermentation. The only modifications I made were to add the sensor, use 14 gauge throughout, and to use velcro tape to attach the components inside. Using wood would have taken up too much room in my tiny project box, not to mention velcroing allows for easier removal of components to work on them.</p><p>Thanks again!</p>
<p>Congrats getting it to work. It looks good!</p>
Okay it's done I made it!<br><br>Couple of changes I made to the original design. I added a 20 amp fuse just to be safe. I also upgraded the wire to 14 gauge. Instead of using the web page to control the power strip, I set up openhab to control it over SSH from a server. The Raspberry Pi primarily acts as a media center with Kodi. <br><br>Thanks for the instructable.
Congratulations! Looks great!
<p>OK i need help. I can not get the relay magnets to close at all. I have purchased two different relay's and both of them seam to have the same issue. I have tried different RPI power supplies but nothing seems to work. The LED's on the relays are all lit, but the relay never closes. </p>
<p>Fixed - Both of my relay boards required 5V to pin 10 of the relay with vcc and jd-vcc jumpered. Works like a champ with the extra voltage nice solid clicks.</p>
Good job! I was wondering if you only has 3.3 volts going to the coils. They need 5. Sounds like you figured it out on your own. Well done.
I had a lot of fun doing this. I built mine into the lid of the project box so i can easily wall mount it some day.
<p>I have a power conditioner set up for my recording equipment. I've been looking at power sequencers with conditioners built in, and the price point doesn't justify the functionality for me. Does anyone know if I can safely plug this project into a power conditioner? Should there be any concerns with the 'cleanliness' or stability of the power coming out of the relay-controlled outlets?</p>
<p>Can I link this up with IFTTT to control individual power outlet based on recipes?</p>
<p>I loved this project. I only put 2 outlets the pi could control. The third is to plug in the pi. I also didn't separate the sockets individually. The cord I used was from a surge protector so I brought the surge switch along with it. All three outlets are connected to the serge protector. The pi is not built into it so I have the connectors coming out the side.</p>
<p>hi rleddington,</p><p>Thank you for posting this. I am trying to do this as well using my raspi2.</p><p>I am relatively a newbie w.r.t to anything electrical, so I have a rather simple question.</p><p>Is the white wire (14 gauge) you talk about solid or stranded? I have a stranded one and it doesn't seem to fit the hole on power receptacle. Pretty sure am doing something wrong.</p><p>Thank you</p><p>Srikar</p>
<p>Just finished up with one! Mine is however powered by an arduino mini acting as an I2c slave. Thanks for the idea!</p>
<p>Looks good. Thanks for sharing.</p>
PLEAse CAN i have more feedback ? ck7up@yandex.ru thank you and please can I use more than 8 channels on one raspberry?<br><br>Thank you for all.
<p>Hello ive been trying to do this for so long, i love your GUI interface! is there any chance you could point me in the direction of the code for this please? And also the pin outs for the Raspberry PI Model B - &quot;Rev 1&quot; i think :/ not sure how to check. </p><p>Thank You</p>
<p>I love this project! Super simple and to the point, and not a ton of resources to drain (I love using the raspberry pi as a web server to host the controls for this too, great idea!)</p>
Thanks! I wish I could take credit for the web-server idea - That was done by &quot;TheFreeElectron&quot; . I just put it to good use. :-)<br>
<p>Can you do this with a 50 amp (normal australian mains socket) instead? what modifications would i need to make?</p>
<p>Yes, but a standard AU mains socket is 10 amps, not 50.</p>
Thought about making a LAN PDU for some time... I like the tutorial, but the relays appear to be rated for 10A, But the outlets are 15A ... might want to reconsider or use two relays per outlet.
<p>Hi</p><p>To fix the problem, you need to use transistors. Take a look on this link: </p><p><a href="https://docs.google.com/file/d/0B5-HND9HJkXWSTQtYlFTZ3VyODA/edit?usp=sharing" rel="nofollow">https://docs.google.com/file/d/0B5-HND9HJkXWSTQtYlFTZ3VyODA/edit?usp=sharing</a></p><p>I followed the instructions and it works fine for me.</p><p>Best regards<br></p>
<p>does it matter what type raspberry pi I use?</p>
<p>I made this, but cannot figure out how to switch the relays from active-low to normal. How do I do that?</p>
<p>Hello! I am ordering all of the parts I need to do this next week. What were the final dimensions for the box you used? That is the last piece I need to order. Thank you!</p>
<p>I was just wondering if you had had any problems with the raspberry pi controlling and powering the relay board? I found a schematic that says the relay board is active low and the raspberry pi is active high so you have to short the relay board to ground to active the relay.</p>
It worked fine except that the web-site displays green when its off and red when it's on. I tweaked the code a little bit so that I could reverse that and show green for on and red for off.
<p>hi. i'm newbie , so how can i control /monitor the lamps from my smartphone,Are there any sripts or coding ?? i would like to learn that, thanks</p>
<p>hello sir I want to control our electrical home applinces through my mobile using raspbery and monitor that how much power is consumption at hat time....</p><p>the data must show graph bw power consumption over time..</p><p>help me.....</p>
<p>Hi, for some strange reason my setup shows for Red button (which normally would be off) the on state. Can you guess what might be wrong?</p>
<p>How I know that my device is ON / OFF when I am at long distance ... Any acknowledgement ? </p>
Yes, when you visit the web-page served by your raspberry pi, you get to see if the devices are on or off just. (Red for OFF, green for ON)
And if any one device is not starting then how we get the feedback that it is not starting ?
EW!!! Who wants your phone???
No kidding. The Motorola Triumph is a LEMON! Can't wait to get a new phone. This thing crashes so often my standard procedure has become - remove battery - put it back in - use phone - repeat. :-(<br>
<p>hi there,</p><p>i have some doubt, since your wiring system is differ from ours in India, and i identify that green wire is ground, yet i can't find that black wire you used is positive or negative charge. can you plz answer for that. thank you</p>
<p>I'm not sure I understand you question but I will try to answer just the same. The power cord has white, black, and green. Since this is A/C there is no such concept as positive/negative wires. Instead you have a ground (green), hot (black) and neutral (white). All of the energy (both positive and negative) come from the black wire. Does that help?</p>
hi there <br> sorry about that, thats not my question, actually its my friend's question. i know how it works but he insist; so i wrote that. yet thank you for your reply
<p>the ground wire (green) is sometimes BARE copper. it depends on the manufacture of the wire. the standard is what was listed above, so if your friend sees no green but does see a bare copper then that is ground. The only other possibility would be the wire is a 2 conductor line that has no ground. Hope that helps</p>
Scratch that last comment I fixed it and found out why one is not working. Notice in the picture how the Q6 has wires not completely in the relay board. That's the problem had to order another relay

About This Instructable


1,929 favorites


More by rleddington: Web Controlled 8-Channel Powerstrip Magic POV Wand (yet another POV toy)
Add instructable to: