I want to use one of the output pins of an ESP 32 to control a device that requires 12 v and uses about 70 ma. I do not want to use a mechanical relay. The ESP puts 3.3 v on the pin and seems to be regulated to 20 ma.
This device outputs an audio signal to an 8 ohm speaker. Best case would be to control the audio circuit by making and breaking the connection in one of the speaker leads but I don’t know how to measure the voltage and current of this circuit.
I’ve already made a couple of false starts, rather unsuccessfully, so I would really appreciate ant help I can get.
The lowest cost and highest fidelity method electronics engineers have used to switch speaker leads on/off for a century now is with an electro-mechanical relay.
AFAIK, even 100 years later, the major practical downside to electro-mechanical relays for speaker switching is the limited lifespan (~100,000 operations). So if you need to switch on/off once per minute (1440 times per day) it may only last ~70 days. Usually speakers only need to switch on/off a few times per day, so a relay can provide decades of zero maintenance high fidelity switching.
What specific reason do you have for not wanting to use a relay for the solution?
How much extra parts cost can you tolerate to avoid a relay in the design?
Can you switch the power to the amplifier, or a low level audio signal, instead of the speaker connection?
PS - I love designing one off custom audio accessories and have done it as a hobby for over 50 years. Can’t remember how many speaker switching circuits I’ve designed in that time for myself, friends, and family.
There are two reasons for avoiding a mechanical relay. I can switch the power to the sound device as it only needs about 70 ma but there is a slight delay when it powers up. Wouldn’t be the end of the world, and is probably better as the device wouldn’t be running all the time with no load on the speaker connections. The other reason is the clicking of the relay. It bothers me.
Then again, if the cost is noticeable, I am willing to use one. With 50 years of experience, I am more than willing to accept your recommendations.
The sound device is a small, low power output device, monaural that plays a loop of the required sound.
This whole mess is to be used on a model railroad layout, as a grade crossing signal. I developed a mechanical system, using 12v relays, that works, but… There are several problems with it. The sound of the relays, and the fact that the LED lights go on and off instantaneously, which is not like the real crossing signals. Got lost in YouTube and came across a video showing the wonders of the ESP 32 microprocessor and thought “I can do that!”. I wrote a sketch that controls the lights exactly as I want them to work. Then I discovered that the ESP 32 doesn’t have the sound capabilities I need without a bunch of other stuff. So I decided to continue to use use the existing sound module. And here I am.
Ah the click, or sometimes much louder clunk, of most electro-mechanical relays. That is definitely something to be avoided, or at least very much minimized, for a model railroad layout.
I’m going to assume that the audio output power of the amplifier is 2 Watts or less.
Given the low power of the audio, need to switch audio, and usefulness of small size, let me introduce you to the miniature reed relay, they are nearly silent.
Since you have 12VDC available I’ll use that for the relay coil because the 10V or lower must operate spec allows lots of voltage drop so nearly any NPN transistor will work for the 3.3V to 12V level convertor.
I’m choosing this one because it’s low cost, can switch 10 Watts maximum, is a brand I’ve used for 40 years (Hamlin was bought by Littlefuse), and comes in an easy to use DIP package.
Here’s a schematic and parts list:
Mfg Part #
Digi-Key Part #
DIODE GEN PURP 100V 200MA DO35
RES 10K OHM 5% 1/8W AXIAL
TRANS NPN 40V 0.2A TO92-3
RELAY REED SPST 500MA 12V
I made the project public so you can copy it and/or add the parts to a cart/list if you want.
Any general purpose small signal transistor should work
Any small signal diode should work
I haven’t done the full math but I believe any resistor value from 1K to 75K should work
For $0.47US more, you can get the relay version with the snubber diode built-in. The built-in diode would improve the snubbing performance.
Thank you so much for your reply!
You are correct that the audio output is < 2 w.
Looking at the package of the relay, I’m willing to be I won’t be able to hear it operate, which makes it acceptable.
Looking at your schematic, am I correct that the 3.3 v supply ground and the 12 V ground can be a common connection? I am referring to the ground symbol at the bottom of the transistor.
And, I can use this relay in series with the speaker?
Which relay contains the snubber diode>? The HE721A1200 or the HE721A1210?
Just out of curiosity, would it be possible to replace the diode and relay from your circuit, and add the sound device in their place? The sound module uses, measured by my multimeter, 68ma when connected to 12 v.
Well I finally got time enough to get back to this project. And It works just like you said it would! I’m glad I used a relay as I ended up needing to use it as the speaker connection. Using it to power the sound module resulted in an excessive delay as the module powered up. So I just powered the module and used the relay to connect and disconnect one lead of the speaker.
Now, I just need to figure how to replace the solderless board with something more robust.
When I want to transfer a circuit from a solderless board, if space in the final device is not an issue, I use a pre-made PCB that exactly duplicates the solderless boards function. Then I literally transfer the parts and jumper wires over and solder them in place.
These are my favorite brand, the ones with PTH (plated through hole) in the name are the solder boards.
Dig-Key doesn’t have it in stock, but if you do a lot of this the super bundle pack is a good value.