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
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
I just soldered the two wires to the board's original built-in microcontroller correspondent legs.
Step 4: Connect the Plug to the Arduino
The optocoupler basically consists of a LED and a phototransistor, the two circuits never touches each other.
Step 5: Add the LED
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
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!
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
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!