1

I need to use some kind of indicator for errors and warnings, I thought a piezo beeper would be perfect since I have one lying around, I did some research online and found out that I can connect it through GPIO and then use python to use it, via the gpiozero module but it barely makes a sound, the best way to describe it is a small 'pop' sound, why is this? Do I need to adjust frequency or something? It's connected to Pin 9 (Ground) and GPIO 17. nothing else is connected.

Code:

from gpiozero import Buzzer
from time import sleep

buzzer = Buzzer(17)

while True:
    buzzer.beep()
    sleep(1)
  • What's the voltage rating for your piezoelectric buzzer. If it's more than 3.3V you'll need a two transistor switch to activate it (at a higher a Vcc voltage) – Dougie Feb 22 '19 at 21:15
1

The docs for Buzzer says:

This interface is only capable of simple on/off commands, and is not capable of playing a variety of tones (see TonalBuzzer).

|improve this answer|||||
0

It is generally inadvisable to put DC across a piezoelectric device. A series capacitor may help with the pop.

The voltage swing of the Pi is very low - running the buzzer in push-pull will increase volume (and eliminate the DC problem). This requires 2 GPIO pins (or extra circuitry).

If the “buzzer “ is intended to run from DC (using internal circuitry) you are using the wrong code.

The "beep" of buzzer seems to be a simple on/off.

|improve this answer|||||
  • The buzzer is a typical one you see used in desktop computer motherboards, not sure if it's active or passive though – Myronaz Feb 22 '19 at 22:20
  • 1
    @Myronaz You should probably use class gpiozero.TonalBuzzer – Milliways Feb 23 '19 at 0:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.