There are already some great projects around here about hacking home automation systems, but what I wanted to do was to control my plugs creatively.

Thats why I decided to do this. To have the most functionalities possible I put a arduino inside the plug switch. 

This way it was possible to add a light sensor to the plug and program it to turn on and off what is connected to it using a laser.

It just compares the last three reads and, if the second value is bigger than the first and the third one, it turns on/off the plug.

Here is a demonstration:

In this project it is required to open a device which has 220V in some parts, so be careful!
I'm not liable for anything stupid you do.

Step 1: Gather the Materials

Materials needed:
  • Home Automation System Switch
  • Arduino - I decided to make one, but you can use any other
  • 4N25 optocoupler
  • 220 Ohm resistor
  • LDR
  • 10k Ohm resistor
  • LED
  • 220 Ohm resistor
  • Wires

Step 2: Open Your Plug

Start by opening the thing, then have a look and try to find what does what. The best way is to find where the pushbutton is connected to the pcb and see if there is anything written there. In my case it was indicated the GND wire and the other one.
If you want you can just connect these two wires to the 4N25 and just simulate the button this way. I preferred to keep looking, find the 5V and let the arduino directly control the relay.

Step 3: Solder the Wires

The technique I used wasn't the most conventional one, but worked which was all I wanted.
I just soldered the two wires to the board's original built-in microcontroller correspondent legs. 

Step 4: Connect the Plug to the Arduino

To let the arduino control the plug without having to share grounds I used a 4N25 optocoupler. Two legs are connected to the arduino and other two to the plug.
The optocoupler basically consists of a LED and a phototransistor, the two circuits never touches each other.

Step 5: Add the LED

Connect to the arduino the LED which will show if the plug is on or off.
It is a basic LED connection, simply connect the long leg to a arduino's digital output through a 220 Ohm resistor and the short the ground.

Now your arduino can already control the plug. With this you can control the plug with your computer, or add sensors to it, which is what I will do on the next step.

Step 6: Add the Light Sensor

To let the arduino know when the laser is pointed to it, I use a LDR.
It is other basic connection, one leg to the 5V and the other connected to an arduino's analog input and to the ground through a 10k Ohms resistor.

Step 7: Test It!

Now that you have all the components well connected start testing the different parts individually.
First see if the arduino can successfully control the plug, to do that, you can just upload the Blink example, only changing the number of the digital output to yours.
Then you need to know if the sensor is reading well, just upload the AnalogInOutSerial example and read the values that the arduino prints to the serial console.

If it all has worked, upload the final program, you can create yours or just upload my which is attached.

Now your arduino should turn on/off the plug and the led when it detects a peek on the light readings.

Step 8: Mount Everything in Place

If you have it all working, mount everything in place, and make it look well.

I didn't have a battery pack or other power source at hand, that's why I used another arduino connected to the computer to give it the 5V.

Step 9: Have Fun!

Now you can turn on and off anything connected to the plug just using your laser.

But it is not the only thing your arduino can do, so keep developing new programs and new functionalities!

<p>very nice</p>
<p>Awesome! Cool use of lasers</p>
Awesome! I had a mini rocket launcher that you pointed a 'ray gun' at a target to launch. I think I will see if I can find it now.
Can u pls tell me how to build an arduino microcontroller used on your project with cheap materials? im from PH thanks by the way and more power
Do you think this switch could work?<br>http://www.amazon.com/AmerTac-RFK100LC-Mounted-Switch-Receiver/dp/B000HJBE68/ref=sr_1_15?ie=UTF8&amp;qid=1303759300&amp;sr=8-15
I would say yes.<br> You should be able to simulate what the RF receiver does ;)
Looks like a cool project. Can you provide a link for a home automation system switch? Oh and I live in America so I need a home automation switch with an american outlet (as opposed to your European one).
I guess that any switch can be used.<br> I bought my kit in a local shop, so I find it quite hard to give you a link...<br> <br> The only one I feel comfortable to give is this, which shows you how to build one:<a href="http://www.sparkfun.com/tutorials/119"> http://www.sparkfun.com/tutorials/119</a>
Ok, thanks. I'll try to look around for one.

About This Instructable




Bio: Hi, My name is Francisco Dias and I'm a student from Lisbon, Portugal. Have a look at my website: http://franciscodias.net/
More by XicoMBD:Create an internet controlled robot using Livebots Arduino controlled Ping Pong Balls Launcher Build a USB Orange Thrower Machine 
Add instructable to: