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
- Home Automation System Switch
- Arduino - I decided to make one, but you can use any other
- 4N25 optocoupler
- 220 Ohm resistor
- 10k Ohm resistor
- 220 Ohm resistor
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!
But it is not the only thing your arduino can do, so keep developing new programs and new functionalities!