Introduction: Sound Activated Outlet
The Clapper was a popular gadget in the 80's and 90's. It let you turn appliances on and off just by clapping. This can be pretty useful, but it has some limitations. First there is the problem of loud noises accidentally turning the lights off. Also, you can't control multiple outlets independently of each other.
So I decided to make programmable version of the Clapper using an Arduino microcontroller. The Arduino lets you set codes for each outlet. This eliminates false triggering and lets you control multiple outlets independently. Your lamp could be turned on and off with one clapping pattern and your fan could be controlled with another pattern.
The Arduino also lets you program how the outlets are turned on and off. For instance, if your internet router needs to be reset, you could program it to turn your internet router off for ten seconds and then turn it back on automatically. Or you could turn a heater on for a few minutes and automatically turn itself off.
Step 1: Watch the Video
Here is a video walkthrough of the project.
Step 2: Materials
Here are the materials and tools that you will need for this project.
2 x 10 kohm resistor
100 kohm resistor
3 x 100 ohm resistor
0.1 microfarad capacitor (capacitor code 104)
Power MOSFET (such as IRF510)
Diode (rated for at least 1 amp)
5 Volt Relay
printed circuit board
Insulated project enclosure
5V power supply/ USB charger
Soldering Iron and solder
Step 3: The Circuit Design
The circuit for this project can be divided into two main parts. There is a microphone assembly and a relay driver.
The microphone assembly is composed of an electret microphone element, two resistors and a capacitor. When the microphone picks up sound vibrations, the output voltage fluctuates in response. This signal is sent to one of the analog input pins on the Arduino.
The relay driver is composed of a power MOSFET transistor, a diode and a relay. The power transistor is added because the relay requires more current than the digital pins on the Arduino can output. So the output signal that is sent from the digital pin activates the transistor and the transistor connects power to the relay and turns it on. The relay either connects or disconnects power from the AC outlet to the attached appliance. The diode acts as a suppression diode and protects the Arduino from voltage spikes that occur when the relay is turned off. If you don't want to build a relay driver from scratch, you can use a commercial relay shield or a PowerSwitch Tail.
If you want to be able to reprogram the clap pattern without modifying the code, you can connect a switch to digital pin 2. This switch connect pin 2 to GND when in normal operating more and connects the pin to 5V to change to programming mode.
Step 4: The Code
Step 5: Prototype the Circuit on a Breadboard
As with any electronics project, you should prototype the circuit on a bread board before soldering it together. This gives you a chance to make any necessary adjustments to the part values or the variables in the code.
First I tested just the microphone assembly with the Arduino. To test the output, I connected LEDs to digital pins 3 through 5. These indicate when the claps are detected, if the pattern is correct and when the output is activated.
You will most likely need to adjust the sensitivity of the clap sensor. To do this, you can change the value of the "threshold" variable in the code.
Once you have the microphone assembly working properly, you can add the relay driver. This part of the circuit rarely needs any adjustment.
SAFETY NOTE: Do not connect AC to the extension cord until the board have been installed in the insulated project enclosure. Having exposed connections with 120VAC is very dangerous.
Step 6: Solder the Circuit Onto a Printed Circuit Board
Once you have the circuit working, you can solder the parts onto a printed circuit board or a perf board. Then connect the board to the Arduino with jumper wires.
Step 7: Mount the Parts Inside an Insulated Project Enclosure
We need to mount the parts inside an insulated project enclosure. It is important that the housing be electrically insulated because we are working with 120VAC.
To mount the boards to the inside of the housing, I used hot glue.
Next, we need to cut some holes for the cables. Position the cables and the switch where they will be mounted. Then mark their position on both sides. Then using a knife or fine toothed saw, cut slots that are just big enough for the wires to fit through. Do the same for the program switch. Then I set the wires and the switch in their slots and secured them in place with hot glue. Once everything is in place, close up the housing.
In some cases it may be necessary to cut/drill additional hole in the housing to allow for sound to reach the microphone.
Step 8: Control Your Appliances With Sound
Now you are ready to control your appliances by clapping. Just plug an appliance into the female end of the power cord and clap out the coded pattern.
In addition to clapping, you can also activate the switch with any other loud noise. You can knock on the wall or the floor. You can whistle. Any noise that exceeds the set threshold can activate the outlet.
The default pattern in the sample code is "shave and a haircut." In the example given, the appliance will turn on for ten seconds and automatically turn off again.
You can modify how the output performs by simply rewriting the code to give the desired response. You can have the appliance turn on or off when signaled. You can have an appliance such as a heater or a fan turn on for a set duration. You can also use it to reset your router by turning the power off for ten seconds and automatically turning back on. The only limitation is your imagination.
Step 9: Optional Improvements
Because the outlet is activated by a specific pattern, you can independently control multiple outlets with the same Arduino. All you have to do is set up more relay driver circuits.
Another possible improvement that could be made on this design is to power the circuit from the input AC power cord. You could do this by simply moving the 5V USB charger to the inside of the enclosure. This would eliminate one of the external cords. You just need to make sure that there is enough room in the housing. Also make sure that the connection are properly insulated.
ThomasVDD made it!
We have a be nice policy.
Please be positive and constructive.