Arduino Audio Triggered Power Switch

18K2624

Intro: Arduino Audio Triggered Power Switch

Ever wanted your home entertainment or sound system to power up itself when plugging in your iPod or other portable MP3 player?

Watch this video to see how it works. Then flip through the steps to find out how to make one using the Arduino controller.



STEP 1: Parts and Schematic

This is what the finished instructable looks like. The required circuit is built onto a Arduino Proto Shield that mates to the Arduino Duemilanove microcontroller.

To successfully complete this project, you will need to know how to solder, how to build simple electronic circuits, and have experience programming the Arduino microcontroller.

Pictured are some of the parts you will need. Here's a complete parts list:

1 ea Arduino Duemilanove or equal ( Radio Shack 276-128 Arduino Uno REV3 will work also) with power adapter
1 ea Arduino Proto Shield (Radio Shack 276-140 is slightly different but will work)
2 ea Phone jacks (Mouser 161-3508-E)
1 ea Terminal block, 5.08mm (Mouser 651-1935561)
1 ea Tactile PB switch (DigiKey SW407-ND)
1 ea 10K ohm variable resistor (DigiKey AAS14CT-ND)
1 ea 2N3904 transistor (Radio Shack 276-2016)
1 ea 47mf 16v electrolytic capacitor (Radio Shack 55047407)
1 ea 1K ohm, 1/4w film resistor (Radio Shack 271-1321)
2 ea 10K ohm, 1/4w film resistor (Radio Shack 271-1335)
1 ea 22K ohm, 1/4w film resistor (Radio Shack 271-1339)
1 ea PowerSwitch Tail II (Adafruit .com ID 268 or Sparkfun.com COM-10747)

And finally, the schematic diagram of the circuit.

STEP 2: Getting Started

Most of the parts will fit directly into the .1 inch spaced holes in the Proto Shield. The exceptions are the phone jacks, the override pushbutton switch and the terminal block. 

Here I've soldered short pigtail wires to each of the terminals of the phone jacks. (To simplify construction, I cut off the two grounding terminals.) When you have the three wires attached, trim them to different lengths. This will make it easier to insert the wires into the Proto Shield one at a time. In the picture, both jacks sit flush against the Proto Shield. 

Using the same technique, I added the pushbutton switch between the phone jacks. 

Turn the Shield board over and bend the wires over and solder the connections. See the picture in the next step.

STEP 3: Building the Circuit.

Positioning of the parts is not critical but with careful placement you can minimize the number of wires that have to be added later to complete the circuit.

In this step, I installed the 10K ohm resistor for the push button switch. Notice the placement allows me to make the needed connections using only the wires on the resistor.

STEP 4: Complete Proto Shield Assembly

Here are top and bottom views of the completed Proto Shield board. Install the components from the top side of the board, bend the leads over as shown and solder on the back side. The terminal block fits into the oversized holed pads near the edge of the Shield.

The brown wires are solid #24 AWG hook up wire. These make the connections from/to parts that don't already have wires attached.

The last picture shows the Proto Shield installed on the Arduino.

STEP 5: Finishing the Project.

With the unit completed, load the sketch below into the Arduino.

Switching of the ac power is safely accomplished using a PowerSwitch Tail. I used some green/white twisted wire I had left over from another project to connect the Shield to the control signal terminals on the side of the PowerSwitch Tail. You can use Cat5 or other low voltage cable since the control wires are isolated from the power line. See the schematic for polarity. 

The plug end of the PowerSwitch Tail goes into the power outlet in the wall. The power plug from my home entertainment system goes into the receptacle on the PowerSwitch Tail. (Actually, everything is plugged into a power strip that then plugs into the PowerSwitch Tail.)

When the control signal to the PowerSwitch Tail is energized, the relay inside the PowerSwitch Tail closes and provides power to the sound system. A LED on the the PowerSwitch Tail lets you know when the control signal is present.

The output of the iPod can go into any of the two phone jacks since they are wired in parallel. The other phone jack feeds the CD or AUX input on my sound system. I used a long phone plug to dual RCA cable.

Setup and testing:

1. Power up your new Audio Triggered Power Switch by plugging in the power adapter into the Arduino power jack.

2. Connect the output of your portable player to either of the phone jacks. I used my iPod.

3. Connect the other phone jack to your sound system. I choose the "CD" input.

4. Turn the 10K variable resistor to the CCW rotation stop.

5. Put your portable player in the PLAY mode to send audio to the instructable. Adjust the volume slider to your typical setting.

6. Turn the 10K variable resistor clockwise slowly until the PowerSwitch Tail triggers and supplies power to your sound system. (If the LED on the Arduino board (connected internally to output D13) lights up but the PowerSwitch Tail does not energize, try reversing the polarity of the control signal wires to the PowerSwitch Tail. When the polarity is correct, the LED on the PowerSwitch Tail and the Arduino will light at the same time. Also make sure the power switch on your sound system is in the ON position.)

7. Adjust the volume control on your sound system to the desired level.

8. To turn off, place your portable player in PAUSE or STOP.

9. The PowerSwitch Tail will de-energize your sound system after about 20-30 seconds of silence. 

Adjustments:

1. The 10K variable resistor controls the input level of the audio signal to the circuit. Advance the control clockwise far enough to ensure the sound system powers up when there is audio present but not too far so that residual electronic noise triggers the circuit. For simplicity audio from only one channel is sensed. If you want to sense audio from both channels, a simple resistive mixer can be used.

2. The push button switch is an override. Momentarily press the switch to toggle the system on or off when the player is in STOP or PAUSE or not connected.

3. Other digital adjustments such as how quickly the switch turns on when the player is first placed into play, how long a silence period before it turns off and the trigger threshold can be easily optimized by changing various parameters in the Arduino sketch. The sketch is fully commented.

Have fun!

17 Comments

Hi there, Stumpled upon your project trying to get some information on a project on my own.
What i am trying to do it use a Arduino between my Chromecast Audio device and my receiver, and make the voltage from the aux in the chromecast turn on my receiver. So when i ask google assistant to play music in my living room it would turn on my receiver as well.
Do you think that would be possible with your project?
And do your receiver turn on by getting power by default?
Because mine need to be triggered on, and i'm considering adding a controller connected to the wiring of the receiver switch to turn it on.
Any one else getting problems with noise coming from the Arduino when the music is muted?
No other reports. What does the noise sound like? Are you using an UNO? None of the official Arduino boards have speakers on them.
It's making a clicking sound that is periodic. It's always there but more significant when the sound is muted. I suspect its because of the parallel aux or some ground interference. (I can send you a sound clip, if that helps)

I have a separate speaker system which uses aux in order to play. I am using a Nodemcu ESP8266 and it does work.

Thanks for the help




hi i want some of this on my multi-room amplifier, but i have no knowledge on soldering, is it possible if you can assemble it for me, i need 4 pieces and buy it from you? from France

Best to find someone local who can build them for you.

hi i want some of this on my multi-room amplifier, but i have no knowledge on soldering, is it possible if you can assemble it for me, i need 4 pieces and buy it from you? from France

hi i want some of this on my multi-room amplifier, but i have no knowledge on soldering, is it possible if you can assemble it for me, i need 4 pieces and buy it from you? from France

Hi, is it definitely a 47mF capacitor? That's an odd value, one that I can't find. Thanks :)

https://www.jameco.com/z/R47-50-47uF-50V-Radial-Electrolytic-Capacitor-plusmn-20-37-_31114.html

Ah so there is a typo in your instructable? I’ll source a 47uF. Thanks

Well presented, I also intend to do something like this but I do not have time to take it

Hello, I am an artist working on an installation and was wondering if I might be able to rent or buy one of these from anyone that has one they would be willing to part with for a while. Thanks!

Contact me at steve@powerswitchtail.com.
Great use of Arduino. A nice and safe alternative to control power may be to use a Wattstopper power unit which is UL approved, has zero voltage switching and as a bonus has DC output at about 150 mA to power your controller. One such unit (B-120 EP) is available from Amazon for about $15. - Enjoy.
I'm reading your code.
soundValue = analogRead(soundIn);
oldSoundValue = soundValue;

Why you don't set directly and you save one assignment and you win some efficiency and readability?
oldSoundValue = analogRead(soundIn);

I say more, you can do this:
oldSoundValue = analogRead(soundIn);
delay(20);
change = analogRead(soundIn) - oldSoundValue;

And if you won't change the variable "m" you can use #define m 5.
The same idea with led and overrideSw. This its like write directly the values in code but you can change it easily. Typically we used capital letter for this definitions, so M, LED, OVERRIDESW ;so when other people read this they know that it is not a variable.

With this you can save 2 assignments and 4 variables. It makes your code more efficient and accurate.