Instructables

Web Controlled 8-Channel Powerstrip

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

Tools
 

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

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 month ago

What software did you use on the PI?

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

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

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

Thanks!

rleddington (author)  Jonnphillip2 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.

mlweiss4 months 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.
AJMansfield4 months ago
120V is hardly 'mains power'. Mains power is usually at least 1kV, and can get to hundreds of kV.
rleddington (author)  AJMansfield4 months 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"??? -
FuzzeeDee4 months 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)  FuzzeeDee4 months ago
Awsome, let us know how the build goes.
trippedout4 months 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 http://www.dyersonline.com/diamond-15-amp-weatherproof-receptacle.html instead right? and make some kind of roof that can protect stuff when its plugged in? would that be all?
alfista26004 months ago
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).

Thanks!
rleddington (author)  alfista26004 months ago
I would check the voltage on the JD- VCC pin. I had the same problem with a weak powersupply. Remember that the Pi only has 3.3 volts on the GPIO pins, but thats not enough for the relay coils. So VCC should have 3.3 V and JD-VCC should have 5 V.
Sembazuru4 months ago
Good attention to detail while checking continuity. At my work we call this checking the beeps and anti-beeps (because most continuity testers beep with continuity).

Out of curiosity, with this setup are you able to log into the Pi via SSH to facilitate updating the onboard software or have the Pi do other things (fileserver while waiting for relay commands)?

Also, I don't know if you have enough space in your enclosure, but it might be a good idea to put a 10A breaker on each of the outlets to protect against overloading any one of the relays. In a project for work I used these: http://octopart.com/1658-g41-02-p10-10a-e-t-a+circuit+protection+and+control-81875, but they might be a bit bulky for your design (and unfortunately would lead to mains being connected to both the lid and the box...) There may be other models out there that would fit this project better...

Sorry, too many ideas... Another idea to keep the AC cord from pulling out of the box too much would be to either use an actual strain-relief bushing, or simply a zip-tie clamped onto the wire on the inside of the enclosure. For safety in case of a catastrophic pull on the cord which partially or fully pulls it out, the hot should be the first to disconnect, and the green ground should be the last to disconnect. Yes, you would still have a dangerous hot flailing about on the AC cord, but none of the attached devices would be floating hot. Maybe have a small diameter cardboard tube (like from an inexpensive wire hanger that has the cardboard tube for hanging slacks) inside the enclosure that the hot wire runs through so it doesn't flail against the Pi while it is loose. (Hmmm... am I starting to over engineer this for you?)

Stop me now before I suggest using GFCI, especially when planning on deploying this near water (like what is at the bottom of live Yule trees)... ;-)
rleddington (author)  Sembazuru4 months ago
Great ideas. I like the idea of adding more over-current protection, especially if you wanted to sell these. I think a breaker may be too big but perhaps an in-line fuse would do the trick. Also a warning sticker letting you know what the per-channel and overall currunt limitations are.

Concerning SSH connections, absolutely yes. Even though the box is in my cold garage, I can remote log into the pi from my warm bed and write all sorts of programs for it. Set up cron jobs to run various scripts, etc. That's my favorite part of this design.
npimpfellow4 months ago
Is there a way to replace the 8-Channel 5V Relay board to turn this into a dimmer?

I'd love to build a remote controlled dimmer-pack this way! Please send me info if you know a board that would work!
rleddington (author)  npimpfellow4 months ago
I'm sure that's possible. A Triac dimmer with zero-cross detection is the type of circuit you would need. I don't know of any commercially available modules with exactly 8 channels, but there may be one out there if you look hard enough. Or you could go the DIY route and design your own. Google "Random Phase triac driver" module and see where it takes you.
Thanks for the info! If you come across a module that might work please link me!
FlintSyrup4 months ago
This will be great for pranks.... Meh hehe >:)
vroom3504 months ago
Great! What kind name App for smartmobile? or use browser?
rleddington (author)  vroom3504 months ago
Yep, just a browser.
I see that use the browser, Wi-Fi between Raspberry Pi and mobile within modem area, couldn't out the world use internet through Raspberry Pi? if so then need App for internet / 3-4G data, and re-programming different code Raspberry Pi for internet outside. I'm using most Arduino.
Leathaldose4 months ago
You know... I frequent a starbucks and I usually bring my own powerstrip... I would have a blast with this. People love to just plug into it even though i have it slightly stashed under my shit. Then they give me nasty dirty looks when i tell them its my personal pwr strip. This would just make it fun,
onemoroni14 months ago
I haven't done any electronics, but I like your well done instructabe and feel I could do this. Having done a lot of wiring in my time I would suggest using stranded wire to make it easier to route and connect the circuits.
rleddington (author)  onemoroni14 months ago
Thanks for the nice compliment. I actually tried it with stranded wire but I liked using the solid better. It was much easier to fit into the terminals and wrap around the contact screws. I was worried one of the strands would get loose and touch something it shouldn't. I don't have to worry about that with the solid core.
You have a good point, mine was from wiring and installing elevators for 20 years in construction where all wiring needs to be stranded. I know electricians who prefer stranded for its flexibility and ease of use here in the US.
rleddington (author)  onemoroni14 months ago
I like your screen name... Are you LDS? I am.
from what i know of building code regulations your supposed to use solid core when it comes to doing any sort of permanent 120v wiring. so in the case of this project not only is it easier to wire but safer. (the building code that i know of is Canadian but im sure the states aren't too far off from being the same way.
Hey may not be talking about the mains, but rather the control panel.
oh btw Underwriters laboratory basically condems these relay modules, learned from self experience http://www.instructables.com/id/BLU-BOARD-control-your-home-with-blue-tooth/
rleddington (author)  kyle brinkerhoff4 months ago
That doesn't sound good. What happened with yours?
nothing, i just got schooled in high voltage control, turns out to be ul compliant the mains power has to be soldered directly to the board
You need to get the ones that has a large current array. look at this one here: http://dx.com/p/8-channel-relay-module-board-w-optocoupler-isolation-blue-works-with-official-arduino-boards-224064 : Using a large current relay, AC 250V 10A DC 30V 10A contacts part independent wiring
rleddington (author)  dregalia4 months ago
Yes, that's the board I used. Great find. Only $9.50 with free shipping (within the US) Thanks.!
do you know if these are UL listed? because if they are im buying one
Pro

Get More Out of Instructables

Already have an Account?

close

PDF Downloads
As a Pro member, you will gain access to download any Instructable in the PDF format. You also have the ability to customize your PDF download.

Upgrade to Pro today!