Picture of 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

Remove these adsRemove these ads by Signing Up
1-40 of 96Next »
Martin AP2 days ago


To fix the problem, you need to use transistors. Take a look on this link:

I followed the instructions and it works fine for me.

Best regards

BobB89 days ago

does it matter what type raspberry pi I use?

I made this, but cannot figure out how to switch the relays from active-low to normal. How do I do that?

tstapert24 days ago
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!
I should have read to the end of your instructable and I wouldn't have had that question.

But thanks for bringing it up for those of us who had the same issue. ^^

Zycro1 month ago

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!

natebman1 month ago

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.

rleddington (author)  natebman1 month ago
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.
HenryA12 months ago

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

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....

the data must show graph bw power consumption over time..

help me.....

joesewer3 months ago

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?

Can you do this with a 50 amp (normal australian mains socket) instead? what modifications would i need to make?

SandeepS24 months ago

How I know that my device is ON / OFF when I am at long distance ... Any acknowledgement ?

rleddington (author)  SandeepS24 months ago
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 ?
bandicoot_5 months ago
EW!!! Who wants your phone???
rleddington (author)  bandicoot_5 months ago
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. :-(
dragons.n.s7 months ago

hi there,

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

rleddington (author)  dragons.n.s7 months ago

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?

hi there
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

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

jaredr098 months ago
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
14, 8:59 AM.jpg
rleddington (author)  jaredr098 months ago
Glad you figured it out. Yea the relay boards are kinda cheap. Good job with the build!
jaredr098 months ago

Having fun working on the project. we are having a problem with one coil not clicking it was 2 coils but i tied in the other 5 volt pin from the pi to the relay board which gave me more power but for some reason one still will not click on the light turns on but still no click. the power supply i am using is 5V 700mA for the output.

hhs999 months ago

What software did you use on the PI?

rleddington (author)  hhs999 months ago
I used wiringpi and the apache web server. Just follow thefreeelectrons instructable to get it all installed and working.
kumaran5129 months ago

excellent article.....i need to control 16 channel relay.....please help me what all to be included

Jonnphillip10 months ago

Hey so I have a really quick/simple question. If you did not want to use this project to control your devices wirelessly but instead have there power controlled by a timer is that possible?

For instance say you had 3 or 4 devices that you wanted to run power to on separate timers so they all turned on and off independently.


rleddington (author)  Jonnphillip10 months ago

Hi Jonnphillip,

Great question. Yes, absolutely it is pretty easy to have any devices setup to go on/off at any time automatically. There are several ways to do it, I simply edited the crontab and used the gpio programs to turn on/off different channels at different times of the day.

mlweiss1 year ago
Great instructable. Thanks for posting. My suggestions would be to add fuse or circuit breaker on the "mains" to relay and 2) label box for inside use only. As a mod for outside use, suggest adding weatherproof enclosure and adding unswitched GFI plug and run "mains" downstream from GFI to protect circuits from ground fault.
120V is hardly 'mains power'. Mains power is usually at least 1kV, and can get to hundreds of kV.
rleddington (author)  AJMansfield1 year ago
You may want to lookup "mains electricity" in google. It looks like I'm not the only one that uses the term to refer to 120V alternating current household power. If I'm wrong, at least I'm not alone. :-)
Dialectal language strikes again. For me, 'mains power' refers to high-voltage transmission lines, (which are normally around 100kV), but it seems that usage is non-standard.
I agree that this comment from AJ was pointless and being an electrician, I'm sure I can safely say that this use of the term will suffice. i guess some people just have to say anything to feel included. - "usually at least"??? -
FuzzeeDee1 year ago
Nice project, think I'm gonna try it. I do have one suggestion though, rather than using the murets (twist on caps for wires) I would use a bus board. Much less chance of overheating or sparking. Bus boards are found at any big DIY store that carries electricians supplies. It will also make for a neater layout but will cost you some space and you can get ones that have a snap on plastic cover to prevent accidents.
rleddington (author)  FuzzeeDee1 year ago
Awsome, let us know how the build goes.
trippedout1 year ago
this is an excellent write up - been meaning to try something like this for a long time but the idea of shocking myself with 120v kept me out of it. one question tho - for a setup like this to be outdoors/weatherproof, id need something like this instead right? and make some kind of roof that can protect stuff when its plugged in? would that be all?
This is awesome. I started doing this some time ago, but didn't have time to figure it all out.

I've got my pi able to turn on all the relays (the LED on each of the 8 relays lights up) but it only seems to be able to turn on the first (far side from JD-VCC) relay on. It is the only one that I can hear a click for and the outlet powers on. Any thoughts on what might be wrong? Relay 7 also will not keep a solid LED (alternates off and on every 5 seconds).

1-40 of 96Next »