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:
Why this might be happening?
How i can modify the amplification circuit to prevent the signal to the speaker from bouncing the power around?
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:
@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!
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
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.