Introduction: Smart Power Outlets
These are Raspberry Pi driven smart power outlets.
The two power outlets are controlled using a web browser or smart phone. It is
also possible to configure the outlets to turn on and off based on the time or
room temperature or combinations of time and temperature. I was also going to add in a light sensor, but never did get around to it. This was a fairly involved project, I wouldn't attempt it unless you have some programming
and electronic skills plus a heap of time on your hands. It is too big a project to go into all the finer details so I will just provide an overview and let you work out the rest.
Step 1: Raspberry Pi Setup
I used a Raspberry Pi A+ because of the reduced cost and size but any model would be suitable.
For this you will need to get Raspbian, a web server and a PHP database up and running on your Pi.
Then get something working (probably easiest setting something simple up on a breadboard to start) - There are plenty of tutorials around on controlling the GPIO pins via a web server and there are several different ways to do it. It will likely take a bit of trial and error so look around and try stuff!
This instructable is a good place to start :)
Step 2: Customise the Code
Once you have a simple test system working expand on the code. Customise it!
Like I mentioned I added a timer and temp sensor to mine, but you could add sensors for light, motion, humidity just to name a few, the possibilities are endless. I also added a simple LCD display and made a slick looking control interface. Here are some screen shots. I even added a "smart plug" icon to my iPhone.
Step 3: Hardware Build
When you are happy with your test system time for your hardware build. I wired my Pis GPIO pins to a mains rated relay switching board that electronically isolates the outlets mains voltage from the Pi. The relay boards can be purchased for a few bucks online (even on eBay). I also wired in a mains to 5V adaptor to run the Pi and relay boards.
Step 4: Further Notes
Just a few more things to think about.
I strongly recommend NOT playing with mains power unless you are
qualified and know what you are doing.
For safety I used a fused mains input and I also opted for
outlets with manual switches in case there is a need to quickly turn off an
appliance without having to find my phone and open the app. I wired the mains
to the relays in the normally off configuration, so in the unlikely event part
of the equipment fails, the most likely outcome will be no power to the
It might be worth adding a shutdown button too, so you can
safely power down your pi without the risk of corrupting any files. I installed
a push button on the back connected to a GPIO pin that when held down for 3
seconds starts the shut down process.
And as with any Raspberry Pi project take a backup image of your
SD card once you are happy with it. You don't want to lose all that work if
ever your system becomes corrupted.
The final product is handy. I've used it to turn on & off lights
and a radio while I've been on holidays, control my Xmas lights, turn on & off
the fan in my bedroom based on temperature and sometimes use it to turn on my
light in the morning to wake me up.
Good Luck and Happy Building :)
Participated in the
Raspberry Pi Contest