Hi! I i have a hard time with audio in general haha, this time, i cant get any output from my piezo buzzer. I can read the 1.8v when probing across the negative side and positive side of the piezo, so the mosfet is working as intended, but i dont get any output, i believe its because of the resistor, i read somewhere that i could use a resitor across the poles, but the original schematic i followed used a diode, could that be the issue?
-
Show us your wiring.
-
Is mcu_speaker 2kHz ?
-
Is the Speaker a passive piezo ?
-
1.8v might be too low.
With no knowledge of "the original schematic" you followed, all is supposition.
Is this what your circuit looks like?
You said:
I can read the 1.8v when probing across the negative side and positive side of the piezo
That reads to me like a steady level, rather than a pulse train. Your particular piezo must be externally driven, correct? And that the frequency response of the piezo is not flat?
here is the reference circuit Controlling DC motors with an Arduino microcontroller
i tried both, both output nothing, so now i just leave it constantly on so that it rules out a frequency driven issue.
its a pcb, there is no “wiring” its as the schematic is. as for frequency, i can change it to 2khz if needed, but for now i am testing it by leaving it constantly on. i believe its a passive piezo. its rated for 1.5v.
-
If it is passive, you will need to key it with a tone of 2 to 4kHz.
-
Out of curiosity, what is the resistance of the device ?
-
Show us how you have it wired/connected to the Arduino.
what do you mean exatcly by device? the buzzer or the whole board, 1.8v to ground?
its not connected to an arduino, its a nrf chip, its simply connected to one of the gpios, and i can confirm that it is correctly going high or low.
-
A passive piezo requires a frequency (as mentioned) to excite the piezo.
-
An active (low impedance) piezo needs a voltage, HIGH (sound) LOW (no sound).
alright, let me look it up real quick. also, when i listen real close, when its supposed to play, i hear 2 clicks and thats it, very subtle. i am playing it at 2khz.
it says
| Driver Circuitry | Transducer, Externally Driven |
|---|
what do you mean 2 thru 4? i tried 4khz, but it didnt change. here is my code if it can help void play_power_on_feedback_tone_only(void)
{
if (!device_is_ready(pwm_dev)) {
LOG_ERR("PWM device not ready");
return;
}
LOG_INF("Playing power-on 2kHz tone");
uint32_t freq = 4000;
uint32_t period = PWM_BASE_FREQ_HZ / freq;
pwm_set(pwm_dev, PWM_CHANNEL, period, period / 2, 0);
k_msleep(5000);
pwm_set(pwm_dev, PWM_CHANNEL, PWM_BASE_FREQ_HZ / 1000, 0, 0);
}
Datasheet here.
Passive, so you need to generate a tone for it. 7.5KHz seems the loudest peak.
It's so small that I think it's best to drive it directly from the MCU pin (no mosfet needed).
The ToneAC library (not tone), with the piezo connected to two pins, would be my preferred way. You can add a 100Ohm to 1kOhm resistor in series with the piezo if you're worried about MCU pin current. It will also make the sound less harsh.
Leo..
So i tried setting it to 7khz, but theres a weird thing going on now, i still get the 2 clicks when its actually supposed to play, but now i also get a constant subtle buzzing even when its not powered on…
here is the buzzing sound
sound.zip (47,2 Ko)
i got it to emit a sound, strangely… at 10hz. ill keep testing. Update: i am able to produce sounds in the range 1 to approx 150 hz and there is still that annoying buzzing sound i cant get rid of, should i get a bigger resistor value?
No, not possible with a piezo sounder.
I wouldn't expect audible sound below about 500 Hz with that piezo.
What is your current code and hardware.
Please full code, no snipets.
I find it hard to believe that the sound you posted is coming from a piezo.
It sounds like a distant vacuum cleaner.
Leo..
there was a fan running in the background,my bad, i fixed the buzzing by increasing the resistor to 10k. I am using a nrf9151 chip, i know their pwm works a bit differently than arduino, so that might be the cause. I sadly cannot post full code as it includes other parts that i cannot share, but i can share the relevant parts if needed. It is using the nrf connect sdk environment tho so i doubt you’d be able to help. i posted here because i figured it was only a hardware related issue.
i can define a period and a pulse only, ill try probing the frequency to see what is actually outputted, but i have an idea of what might be causing this, ill update you.



