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

1-40 of 117Next »

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.

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 "WHEN RELOADED OR ON DIFFERENT BROUSER" i then have to click the button twice to get it to go off.

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.


I can provide the code i have if somebody can help me out.

Thank You

tstapert9 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?
tstapert tstapert9 months ago
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.
tstapert tstapert9 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. ^^

The-Dude tstapert8 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 !

JesseBuesking made it!22 days ago

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.

Thanks again!

rleddington (author)  JesseBuesking21 days ago

Congrats getting it to work. It looks good!

nrune made it!2 months ago
Okay it's done I made it!

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.

Thanks for the instructable.
rleddington (author)  nrune2 months ago
Congratulations! Looks great!
nrune2 months ago

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.

nrune nrune2 months ago

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.

rleddington (author)  nrune2 months ago
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.
amiller110 made it!3 months ago
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.

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?

yashrg4 months ago

Can I link this up with IFTTT to control individual power outlet based on recipes?

kelly.s.wilson.355 made it!5 months ago

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.

S J SrikarN5 months 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!6 months 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)  fatlard19936 months ago

Looks good. Thanks for sharing.

ckalla6 months ago
PLEAse CAN i have more feedback ? ck7up@yandex.ru 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

ppeters05027 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)  ppeters05027 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.
Martin AP8 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

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

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

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

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

SandeepS21 year ago

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

rleddington (author)  SandeepS21 year 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 ?
1-40 of 117Next »