Using Tone() with a piezo speaker makes V+ and Vin periodic...help!

Hello! I'm experiencing an issue with a project and wondering if yall can help. I am using the Tone() function on pin 6 of an Arduino Uno R3 to drive this piezo speaker.

I've tried several connection circuits including connecting the piezo speaker directly to the Arduino with no resistors and the two simple circuits below.

In the first circuit i have tried R1 ranging from 100 Ohms to 440 Ohms. However, the volume was not nearly loud enough, so i tried the second circuit.

In the second circuit, designed to amplify the volume out of the speaker, R2 = 440 Ohms and the transistor is this (its just what i could quickly find for free).

I'm using some other sensors as analog inputs to the arduino. Those sensors are powered by Vin (not 5V!), which, in this case, i have set to 12V (powering the arduino with a wall wart). When the tone is playing, i noticed that the other sensors (whose values i'm printing to a screen) started to get noisy.

When i looked at Vin on the oscilloscope without a tone playing, it displays a constant voltage of approximately 12V, as expected (see response for photo).

However, when the tone is playing, there is a frequency to the Vin! (pictured in my response below, because new users can only put 1 multimedia item in a post).

This also affects the +5V power supply pins (not pictured) and happened for all of the circuit configurations described above. Using the first circuit (speaker and R1 in series) gave a larger periodicity in power for smaller values of R1 and a higher speaker volume. This periodicity in power is preventing the other analog sensors from giving reliable readings while the Arduino is outputting a tone. Heeeeelp!

Does anyone have any suggestions as to:

  1. Why this might be happening?
  2. How i can modify the amplification circuit to prevent the signal to the speaker from bouncing the power around?

Thank you!!!

Here is the normal oscilloscope reading of the Vin pin:

And here's what the same pin looks like when the tone is playing. The oscillations in Vin are perhaps 0.6V from crest to trough.

Thanks!!!
-ask53

Appears you have an 8 Ω speaker, not a piezo speaker.

Power the sensors from a regulated voltage supply to avoid the problem.

The speaker is probably overloading the on board voltage regulator. Power the speaker from 12V, not 5V, and use a resistor (start with maybe 100 Ohms and experiment downwards) in the transistor collector lead to reduce the volume.

However, it is much better for the speaker to use an AC coupled connection. The following should work:

Capture

@LarryD whoops my bad, thanks for pointing this out!

@jremington thank you for the circuit suggestion, i'll try it out soon -- as a dabbler in electrical engineering and circuitry with almost no formal training into the theory of circuit design, i so so so appreciate it when folks offer circuit diagrams!

Hi @jremington, thanks again for the circuit design. I got it set up and it works perfectly at not overloading the arduino's voltage regulation system -- the scoped power pins look smooth and consistent! However, the speaker is now so quiet i can barely hear it (i'm not using any resistance between 12V+ and Q1 at the moment. Any thoughts on how to increase the speaker's volume? Thanks!

Buy a proper power amplifier for your 8 ohm speaker

Or

Buy a passive piezo buzzer.

mkay thanks @LarryD

@jremington

Why did you choose a resistor of 1k? No wonder that it does hardly make any noise... is it to protect the npn from overheating?

Lower the value of R1 to suit. It will be VERY loud at 10 Ohms.

Hi @build_1971 and @jremington, thanks for weighing in. My understanding is that the circuit of R1, C1, and R_speaker on jremington's design is an AC/DC filter such that higher frequency signals will pass through C1 and the speaker while DC signals will flow through R1 and to GND. Is this correct?

I'm sorry analyzing this circuit is out of my comfort zone -- would one of you mind explaining why adjusting R1 would impact the volume of the speaker? Does it increase the current through the speaker? Or would it pull more power from the transistor? Thank you!!!
-ask53

Reducing R1 lowers the output impedance of the emitter follower amplifier, and increases the power transfer to the load.

As R1 is reduced, the amplifier will draw more current from the power supply.

:star_struck: :star_struck: got it, thank you!!!

With 10 ohms you will need a power transistor...
5V 10 ohms is 0.5 amps 0.5 amps*7V = 3 W.
BC547 will blow...

Thanks all for your support. I ended up caving on creativity and learning and instead following @LarryD's advice. I got a LM386 for $1.50 and it works just fine. With the minimum gain (20), i'm getting sound that's loud enough!

However, when i first connect the speaker to the arduino following the manufacturer-recommended design (section 9.2.1 of this datasheet) i end up with a loud buzzing sound when the arduino turns on. I declare the output pin early in the code and when that line of code is reached, the buzzing sound turns off. Any suggestions for how to avoid that buzzing? Thanks all
-ask53

An Arduino input pin is essentially an open circuit, so the amplifier will pick up electrical noise from the environment. Use short and/or shielded leads, and connect all the grounds.

You should have a DC blocking capacitor (1 to 10 uF) between the Arduino output and the amplifier input.

  • Make sure you have the .05uF and 10R on the output.

  • You can’t try adding power supply decoupling to pin 6.

  • Try adding a 4k7 resistor on pin 3 to GND.

  • A bypass on pin 7 may help.

1 Like

An LM386 is from the times of the L293D and LM741.
50+ years on there are more efficient class-D amplifiers.
Look for PAM8403 boards on ebay.
Leo..

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.