2
\$\begingroup\$

I am pretty new to electrical engineering, so please bear with me.

I am trying to activate a 5V relay when it detects sound coming through a 3.5mm jack. Can anyone help me figure out how to do this?

\$\endgroup\$

2 Answers 2

4
\$\begingroup\$

Since you are pretty new to electrical engineering, I will give you a complete circuit, with explanation.

enter image description here

Turning on a relay requires a fair amount of current (~50mA) which is more than typical ICs want to source directly, so usually a transistor is used to take a small control current and switch on the large relay current. This circuit uses any generic PNP transistor, e.g. 2N3906.

The chip shown is any generic “open collector comparator”, e.g. one section of an LM339. These devices pull low (to ground in this case) when their ‘-‘ input is higher than their ‘+’ input. This condition happens when any audio signal shows up that exceed the threshold voltage (set by the 1M / 22K resistor but can be adjusted for your desired trigger point).

When a positive audio peak exceeds the threshold volage then the comparator goes low, discharging the capacitor and turning on the PNP transistor and hence the relay. The capacitor will continually get reset as audio continues to come in.

When audio stops, the comparator’s ‘-‘ input stays at ground and now its ‘+’ input is greater so the comparator goes high. But “high” for an open collector device really means that it disconnects entirely from the output so only the 1M resistor is left to slowly charge the capacitor, eventually all the way to the +V rail at which point the transistor turns off (because its base-emitter voltage is zero). The 1M / 1uF creates a time constant of a second or two that keeps the circuit on after audio goes away. Making C bigger will keep it on even longer.

The +V voltage rail must be chosen to match the relay’s specified voltage. Typical relay voltages are 5V, 9V and 12V. Depending on the +V you end up with you may want to fiddle with the 1M/22K values to get the audio turn on threshold right.

For simplicity you may be tempted to run the whole thing from a 9V battery. That would probably work but not for very long: the ~50mA constant current requirement would drain the battery quickly. Better to use 5V from a USB port or a 5/9/12V DC adaptor.

Lastly, a diode (any diode) is usually placed across the relay coil to give the pent up current in the coil a discharge path when abruptly turned off.

\$\endgroup\$
3
\$\begingroup\$

This may be a bit much for a single question here, but I will tell you what I have done in the past for similar projects to get you started.

Start by using a basic opamp circuit to take the signal and pass it to the rest of our circuitry. Depending on the levels, you will probably want some amplification at this stage. This first stage is mainly so we don't affect our audio signal.

After this I will usually do a simple band-pass filter using just resistors and capacitors. This will eliminate noise and frequencies outside our audio range from affecting the operation of the circuit.

Next, you want to rectify the signal. This can be done with just a diode.

You then need a way to turn these pulses into a DC level. You can usually just use a resistor and capacitor in parallel to ground after the rectifier for this.

Sometimes a second stage of amplification is useful here. You can make the gain adjustable so you can tune the rest of the circuit as needed.

Next comes a comparator circuit which looks at this DC level and compares it to a fixed DC level. Set it up so when that level is exceeded, the comparator output switches. Make the fixed DC level so you can adjust it to tune the circuit.

Use the output of the comparator to drive the relay. You will most likely need a transistor here to provide enough power for the relay coil.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.