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 106Next »
S J SrikarN23 days ago

hi rleddington,

Thank you for posting this. I am trying to do this as well using my raspi2.

I am relatively a newbie w.r.t to anything electrical, so I have a rather simple question.

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.

Thank you


fatlard1993 made it!1 month ago

Just finished up with one! Mine is however powered by an arduino mini acting as an I2c slave. Thanks for the idea!

rleddington (author)  fatlard19931 month ago

Looks good. Thanks for sharing.

ckalla1 month ago
PLEAse CAN i have more feedback ? thank you and please can I use more than 8 channels on one raspberry?

Thank you for all.

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 - "Rev 1" i think :/ not sure how to check.

Thank You

ppeters05022 months ago

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!)

rleddington (author)  ppeters05022 months ago
Thanks! I wish I could take credit for the web-server idea - That was done by "TheFreeElectron" . I just put it to good use. :-)

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

Yes, but a standard AU mains socket is 10 amps, not 50.

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.
tstapert4 months 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?
The-Dude tstapert3 months ago

The issue is that in the examples / pictures in the article the "wrong" relay board receptacles are used. Each relay has 3 receptacles, left one middle one and right one.

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)

I personaly find this safer and more practical as by default now all outlets are in the off position by default.
But there is no right or wrong here.

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

Did I mention to remove the main power first :D ?

By the way Thanks rleddington for writing this article I found it verry usefull !

tstapert tstapert4 months ago
I just edited the code and basically switched high and low output and everything works great. Thanks again!
tstapert tstapert4 months ago
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. ^^

Martin AP3 months 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

BobB83 months 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?

Zycro4 months 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!

natebman5 months 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)  natebman5 months 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.
HenryA15 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.....

joesewer6 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?

SandeepS27 months ago

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

rleddington (author)  SandeepS27 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_8 months ago
EW!!! Who wants your phone???
rleddington (author)  bandicoot_8 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.s10 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.s10 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

jaredr0911 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)  jaredr0911 months ago
Glad you figured it out. Yea the relay boards are kinda cheap. Good job with the build!
jaredr0911 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.

hhs991 year ago

What software did you use on the PI?

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

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

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.


1-40 of 106Next »