Using transistors to boost power to a Piezo transducer

So i'm now starting to use transistors for the first time by intention (as opposed to "just copying" a TIP120 example circuit)

i wanted to boost the sound from a Piezo transducer which by tone() was too soft to be heard properly.

there were several threads on this, suggesting to use a transistor, but they didn't seem to come to a conclusion as to whether it worked or not.

it's a simple circuit like so;

the code is still the same, a standard toneMelody.ino - but nothing happens.

i have tried putting in a bulb in the circuit (and Blink.ino) to confirm the transistor is indeed switching current on and off, but when it is the piezo transducer and toneMelody.ino - nothing...

is there a particular specification that a transistor needs, so as to be able to duplicate the square wave for tone() - maybe it's not matching the frequency applied at the Base ?

i am using a generic 2N2222.

Hello,

Like you correctly mentioned there is an audible frequency for humans, this is, for young people between 150Hz and 22kHz. As we grow older we mainly loose the ability to hear the higher frequencies. You probably want to check what frequency your output has. What you mentioned about the transistors frequency limitations, is certainly true, but 20kHz shouldn't be a problem, although I haven't checked the datasheet. I think your resistor might be on the high side, but check your frequency first.

Sincerely yours,

Mike

BabyGeezer:
i have tried putting in a bulb in the circuit (and Blink.ino) to confirm the transistor is indeed switching current on and off, but when it is the piezo transducer and toneMelody.ino - nothing...

Change the base resistor from 5k to 1k. See if anything happens (I don't think it will)

Then add a 100ohm resistor across the piezo.

Let us know what happens.

Yours,
TonyWilk

The good news is... Your schematic is OK! (The 5K resistor seems a little high, but Id expect it to work.)

Double-check the schematic against your actual wiring and check the 2N2222 datasheet to make sure you've got the base/emitter/collector correctly identified.

Is your 9V battery dead?

Maybe the transistor is bad?

i have tried putting in a bulb in the circuit (and Blink.ino) to confirm the transistor is indeed switching current on and off,

And that worked? I assume the "bulb" was an LED & resistor?

which by tone() was too soft to be heard properly...

...and toneMelody.ino - nothing...

Did you try regular 'ol tone() with the transistor?

Did you try toneMelody without the transistor?

BTW - Double the voltage would b 6dB louder, which is noticeably louder, but not a whole-lot louder.

Maybe I should be a little less cryptic...

The reason it is not working (and will work with a resistor across the piezo) is because a piezo is basically a capacitor.

The transistor turns on, the capacitor charges up.

The transistor turns off, the capacitor stays charged.

Transistor turns on again, nothing happens.

With the resistor in place it discharges the piezo 'capacitor' when the transistor is off.

Yours,
TonyWilk

i tried dropping the resistor to 2K Ohm but that didn't change anything.

DVDdoug:
Double-check the schematic against your actual wiring and check the 2N2222 datasheet to make sure you've got the base/emitter/collector correctly identified.

yes, i did this very carefully to confirm which was the Base.

DVDdoug:
Is your 9V battery dead?

it's possible it's starting to drain - i have a "LED voltmeter" on the power rail and i noticed it's quite below 5V (usually 4.8V but this time around 4.5V - while powered from the USB)

DVDdoug:
Maybe the transistor is bad?

perhaps, i have others i can try...

DVDdoug:
And that worked? I assume the "bulb" was an LED & resistor?

yes - it's an actual filament bulb that can take the 9V.

DVDdoug:
Did you try regular 'ol tone() with the transistor?

i tried a simpler sketch which has worked but that didn't sound, it did when the piezo was connected directly to the Arduino pin (5V).

DVDdoug:
Did you try toneMelody without the transistor?

yes, direct from the Arduino pin.

DVDdoug:
BTW - Double the voltage would b 6dB louder, which is noticeably louder, but not a whole-lot louder.

sigh, not worth the exercise then, huh ?

in the meantime - i think something went bust... :frowning:
got the "avrdude: stk500_getsync(): not in sync: resp=0x00" error showing.

now i can't even upload a simple Blink sketch !
(have tried reloading the IDE - and have confirmed on another Uno that communication is okay - uploaded a Blink sketch to that and it worked without the error above.)

i don't know if restarting Windows (XP!) will make a difference if the Uno works.
(the one i'm using now is a Nano (clone) from ITEAD Studio) - i fear the worst...

i can confirm the battery is "still okay" - it's actually 8 x 1.2 Eneloops and the "voltmeter" shows 9.99-10.0 V

it's really just used as a reference indicator.

so the low 4.48-4.5V reading looks bad.

i stuck an LED on the same out-pin and it lit up - on the tone() which i believe is the last sketch that managed to get uploaded.

would that indicate the Nano is still okay ?

would that indicate the Nano is still okay ?

That's actually a very good question. Is there a way to test your Arduino, or is this done when you try to upload a sketch?

Mike

Try driving the piezo using the tone() function - does it work?

There are various small audio bridge amplifiers which will double the voltage swing.

You may need much higher voltages...

Allan

FFS !!!

R E A D M Y E A R L I E R P O S T S

Mikeb1970:
Hello,

Like you correctly mentioned there is an audible frequency for humans, this is, for young people between 150Hz and 22kHz. As we grow older we mainly loose the ability to hear the higher frequencies. You probably want to check what frequency your output has. What you mentioned about the transistors frequency limitations, is certainly true, but 20kHz shouldn't be a problem, although I haven't checked the datasheet. I think your resistor might be on the high side, but check your frequency first.

Sincerely yours,

Mike

The piezo that came with my Arduino kit just made a click. Another one made a tiny bit of tone if I put my ear right on it. Then I got in-the-ear hearing aids and both now make a nice, loud tone!!!

Paul

TonyWilk:
FFS !!!

R E A D M Y E A R L I E R P O S T S

i have, "with a resistor across the piezo" - that means in parallel, right ?

the problem is i can't even connect now - so there's a more pressing problem than trying out your solution.

Paul_KD7HB:
The piezo that came with my Arduino kit just made a click. Another one made a tiny bit of tone if I put my ear right on it. Then I got in-the-ear hearing aids and both now make a nice, loud tone!!!

Paul

well, i can confirm i haven't gone quite tone deaf yet - as i said, the piezo works from the Arduino pin - i CAN hear it.

Mikeb1970:
would that indicate the Nano is still okay ?

That's actually a very good question. Is there a way to test your Arduino, or is this done when you try to upload a sketch?

Mike

i have no advanced knowledge of electronics, so i wouldn't know where to begin to try and probe the Nano.

beyond the LED comes on, and uploading proceeds okay - i don't know how else to check if the Nano is still working 100%.

it is possible that the external voltage 8x1.2V got connected to the Nano power rail (while connected to the computer via USB) - the Nano Spec page says recommended input 5-9V - this might have pushed it too far ?
(i understand the Uno also has an extra feature that also protects surges to the computer USB port, so i thought maybe the COM port got "fried" - i assigned a new COM port but that didn't help - i still get the avrdude: stk500_getsync(): not in sync: resp=0x00

i have uploaded a Blink.ino (and even the toneMelody.ino) to another board and that went fine, so the PC and IDE are working it would seem.

is that "LED voltmeter" reading of less than 4.5V any indication of "not a 100%" Arduino.
(as comparison, the same 'measurer' on the other board (Uno) showed 4.77V - it wouldn't be case of "different breadboard, different reading" would it ?)

can anybody suggest the next trouble-shooting step ?

i have now tried a "diagnostic" using Nick Gammon's code from this thread.

https://forum.arduino.cc/index.php?topic=268755.msg2113631#msg2113631

the result;

Atmega chip detector.
Written by Nick Gammon.
Version 1.20
Compiled on Feb 3 2018 at 14:31:16 with Arduino IDE 105.
Attempting to enter ICSP programming mode ......................................................
Failed to enter programming mode. Double-check wiring!
Programming mode off.

i did a double-check, even trying the other RESET pin on the Nano and even connecting the jumper wires right up to the 5V and GND pins, instead of on the power rail, to which they are connected anyway.

does that failure mean the Atmega is done for ?

being a SMD component, i guess there's also no chance to even salvage anything from the Nano ?? :confused:

I know this is an old topic but since no one ever confirmed -the answer is in fact that the piezo needs a resistor in parallel when used with this circuit

It doesn't when directly connected to the arduino pin so it must sink current when the tone low function goes low... when you add a transistor the negative pin of the piezo (in this diagram) stays high due to the capacitance

I have spent an embarasing amount of time fighting this and its surprising how many circuits don't show this so I assume they are all active buzzers not passive/piezo ones- so thanks @TonyWilk

BabyGeezer:
it's a simple circuit like so;

the code is still the same, a standard toneMelody.ino - but nothing happens.

Yes nothing happens because a piezo element is a capacitor(*), so DC drive is not possible, you must use
AC drive, aka push-pull, and expect no net DC current to flow.

(*) all large-value ceramic capacitors are made out of the same basic material type as piezo transducers

If you connect the piezo to TWO Arduino pins, and use the toneAC library, then you can drive the piezo push-pull.
That 5volt H-bridge, delivers the same amplitude as a piezo on a 9volt battery.
Leo..