How to drive the piezo buzzer?


#1

I have the spark maker kit.
Among the goodies there is piezo buzzer. According to its documentation. It needs from 4V to 7V to make it work.
I am using an analog output + 330ohm resistence and I can hear it almost good enough, but I would like to make it louder.
Is there any intelligent way of doing this only with the power from the core (3.3V) or would I need an external power source?

I only need to do 3 or 4 ‘beeps’ to call for attention, I do not care much about the quality of the sound as long as it is heard.


#2

Maybe you could use a transistor and the 5V pin to fuel the buzzer?


#3

Looks like the voltage and current are perfect for hooking the piezo directly up to one of 3.3V 20mA outputs of the Core. Since you are using the analogWrite(), you are stuck with 500Hz which is a pretty low frequency. Your piezo’s resonant frequency is 2300Hz, so will therefor be louder if you drive it at that frequency. It’s also easier to hear a 2 - 4kHz frequency.

You could try my Remote RTTTL library, but it might be overkill for a few beeps. However, it might be more FUN! xD

You’ll want a D7 note (2349Hz). Try this song:
char *song = (char *)"2.34kHzBeeps:d=4,o=7,b=240:d,p,d,p,d,p,d,p";

I just pushed a change to the code that fixed the octave selection, it was one lower than selected… at the same time I added your 2.34kHz beeps… tested and measured as 2.34kHz. Play with speeding up the beeps or slowing them down with the BPM (b=240) or default duration (d=4) or the notes themselves (d vs. 8d, vs 4d), or tweaking the pitch (c vs e vs a etc…)

You can even just strip out the tone() function and send it tone(D6, 213, 500); to play a D7 note on pin D6 for 500ms, then roll your own delays.


#4

I just plugged it into the breadboard – jumping between one of the digital pins and ground – and set the digital out HIGH. My cats and my wife jumped. For short beep sequences, this should work fine if you’re okay with the default pitch that will come out.


#5

Derp. So it’s a self resonating piezo buzzer!?? &@^#$&^%$ haha. So much for that datasheet. >.>


#6

I just wanted to point out the URL for the Spark Core Maker Kit buzzer datasheet changed. Here’s the new one: https://docs.particle.io/assets/datasheets/makerkit/buzzer.pdf