Smart Power Outlets




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

Raspberry Pi Contest

Participated in the
Raspberry Pi Contest

Be the First to Share


    • For the Home Contest

      For the Home Contest
    • Big and Small Contest

      Big and Small Contest
    • Game Design: Student Design Challenge

      Game Design: Student Design Challenge



    Question 3 years ago on Step 4

    Hi! Just wanna ask where did you base your programming and if you have a schematic diagram we can work on?thanks!


    7 years ago on Introduction

    Where can I find the smart plug software and what software are you using on raspberry Pi? Do you have a schematic for the hardware you've made?


    Reply 7 years ago on Introduction

    Hi Canadoru, unfortunately it is not as simple as uploading a bit of software. The system has a couple of programs, a webserver and some databases all sharing variables and working together. Here are the tutorials I started with; this one for the GPIO pins/php/webserver. If you want a simple on/off via your phone this will do that.

    and this tutorial for the LCD

    These tutorials are the skeleton I built my project around, but by the time I added temp sensing and a timer and prettied the whole thing up it ultimately only made up only small portion of the finished code (<5%) . I didn't intend this instructable to be a simple ready made build with software and a schematic to copy, but rather to provide an idea and inspire others to take on a meaty project with some development work required.

    I hope these tutorials help point you in the right direction. The basic software framework and hardware schematics are all there.

    BTW the relay switching board used is similar to this