Speaker circuit

Here are 2 drawings of a circuit
With Esp32, I need to generate few beeps using tone() of different milli seconds at specific time

This circuit I found on web, thanx to it's author
Just i changed Esp32 instead of Nano
used: Esp32, 8ohm 0.5w speaker, 2N2222 transistor, 1k resistor
It is working perfect

Just I want to know that,

  1. Whether I need to add more resistors or transistors to safe guard this circuit ?
  2. Can I run this circuit on 12v instead of 5v ?
  3. Shall I add diode for safety ?


Different circuits.

In the second one, the fritzing breadboard view, there is no connection between the 5V pin of the Nano to the speaker.

Did you make these in separate fritzing files? Because if you had made them as two views in the same file, fritzing would have pointed out that there was a difference to you.

Could you not find a library of fritzing parts to download that include an ESP32 board matching the one you have?

correct
I did not noticed this

but I took from a single web page - How to amplify your ARDUINO tone’s the easy way |

In theory, this circuit could damage itself in several ways.

When the Arduino pin is high, 5V will be connected across the speaker, which has 8 ohm resistance. So the current that would flow would be 5 / 8 = 0.625 Amps. The power dissipated by the speaker would be 5 x 0.625 = 3.1 Watts. That exceeds the speaker's 0.5W rating by a long way. 0.625A also exceeds the maximum current rating of the transistor, which you can find in its data sheet. Finally, 0.625A exceeds the maximum 0.5A that your USB socket allows, which might cause the PC to cut power to your circuit to avoid damage to itself. If it was allowed to exceed that 0.5A, the Arduino might be damaged.

This is all a simplification. The Arduino pin will be emitting a PWM signal, and the speaker will react differently to that, but I'm not sure how to calculate what the current will be.

But I would recommend putting maybe a 100 Ohm resistor in series with the speaker for safety.

It might be better to get a small amplifier module:


This should allow the speaker to be much louder, while reducing the risk of burning it out.

That said, the one above has a 3W per channel maximum output, so could still damage your 0.5W speaker. So a pot to reduce the input signal voltage from the Arduino would be a good idea.

Not for long, see posts above. Z-HUT knows just enough about electronics to be dangerous.

A selection of small, inexpensive audio amplifiers can be found at Adafruit.

I used this now - TDA2030a
It works in single tone function with mini speaker box

but when it connected with my PCB, where Esp32 is working on lot of tasks together, speaker box makes humming

any idea ?

How are you supplying power to that amplifier?
What else is on your "PCB"?

I powering Esp32 through 5v 1amp power adapter
Seperate power supply to this amplifier

Esp32 unit is actually a countdown timer, it's PCB is having 4 buttons, 1 Max485, 1 seven segment, sending signal to P10 display

What voltage and what type of power supply.
That is a very high powered amplifier, may not be suitable for your application.

This module would be more appropriate and can run on 5V

Having this also
Making same humming

Again I ask what voltage and what type of supply.
Poor or improper grounds will ofter produce hum.

This is my power supply

This of full unit

2 red wire coming from power supply and blue/green going to amplifier

Is the power supply ground the same as the audio signal ground on your PCB?

1 Like

Yes
Power supply ground (incoming)
PCB ground
Amplifier module ground
Audio signal ground
All are common
Connected together
A common trace running with all

Well for debugging purposes, can you supply the amplifier with a separate supply, a 9V battery or a 5V power bank would be good.
If the hum goes away, then you know it's from the power supply.

Checked all grounds
All ok

I power LM386 and Esp32 through same power adapter 5v 1amp

Just changed 1 connection
Signal (green)- 1k resistor - 1N4007 - LM386 IN pin (gray)

Working good
No humming as it was

Shall I change resistor value ?
Or sequence of signal ?

Well I can't explain why doing that would eliminate the hum.

But it's true

Just tell me please
Whether register value is ok or need to change
Or need to change the sequence of register and diode ?

TIA....