So today we will be doing our first complete project. We will be building a smart power strip which can be controlled from anywhere in your home as well as possibly the internet.
- A power strip
- Relays(number depends on the number of sockets in your power strip)
- Some basic screw drivers(too match the screws on your power strip)
- Some connecting wires
- Soldering Iron(Depending on your power strip)
WARNING: THIS PROJECT INVOLVES WORKING WITH MAINS LEVEL VOLTAGE LINES!!! PLEASE BE CAREFUL!! I CANNOT BE HELD RESPONSIBLE FOR ANY DAMAGE OR BODILY HARM CAUSED DURING OR AFTER MAKING THIS PROJECT!!
A power strip as we all know, is just an extension cord with more than one power socket at the end, while there are different types of power strips(Surge Protecting etc.), for the purpose of this project a basic one will do.
A relay is an electrically operated switch, where basically a current is used to turn a switch on or off. Relays can be of many types, the one I will be using is an electromagnetic relay, but feel free to use anything that matches your requirements. The relays I will be using will also be optically isolated, which means that the driving circuit of the relay is kept completely sepe csc 1rate from the mains circuit it controls. To make my life easier I got a board from ICStation that is already optically isolated.
Setting up the power strip
Make sure the power strip is UNPLUGGED!
Unscrew all the screws at the back of your power strip
Take off the top cover and examine the circuitry
The power strip I am using has individual switches for each plug, it also has a convenient hole right after the switch which we can use to connect to the relay. If it doesn't have individual switches, connect the relays directly to the hot terminal.
Connect some wire to each of these holes. These wires should be long enough to reach the desired place of the relay board. I'm using red wire because these will be HOT wires, so please be careful when handling. As you can see I removed the switches to make the terminals accessible.
Soldered the wires to the terminals for good measure.
Reassemble all the components that have been removed and route the wires in the desired direction.
Mark some points on the outer shell where these wires will come out of the shell and drill holes of the appropriate size. If you have space you can also route them through the strip and take them out of the strip with the mains power cord.
Now connect another wire to the hot wire of the mains cord and bring it out of the strip(you can use the hole of the mains cord or drill another whole in the shell.
Assemble everything back together. I used some cable manager to keep all the wires together.
Connect the red wires to each of the inputs of the relay's, I used the NO port as those are normally open, and the relay is closed when a current is applied to it. Connect the wire from the mains hot wire to each of the COM ports of the relay's.
The final circuit diagram looks like this:
Connecting to the Pi
All you need to connect are the GND and V+ pins to the 5V and GND pins of the Pi, and then connect the relay inputs to any GPIO of your choice, I used 4,17,27,22.
Now, this is the easy part, you are completely flexible to write any kind of program you want, it could be a web server, a mobile server, a simple scheduler etc. All you need is to toggle the GPIO pins on the Pi to turn it on with something like
GPIO.output(23, GPIO.HIGH) in python. I will be updating this post with a full Android App controlled web server in the future, but for now I will be just leave the implementation up to you!
This project has lots of possibilities, I personally use it by running a webserver on the pi and then controlling the power strip from the browser of any internet connected device (smartphone, computer etc) in my home.