1

Buzzer (all it says on the back): 3 VDC, 15 mA, 75 dB

I have a simple breadboard circuit with a LED that works. I'm now perplexed (again, I know zero about circuitry) how to add a working buzzer. I first tried adding the buzzer (in parallel? I guess?) to the same GPIO pin that activates my green led, and I get an extremely faint sound. Then, I hooked it to its own GPIO pin without a resistor at all, and it works, albeit sounds a bit low pitched (maybe thats normal for this buzzer).

Question #1 is: what is the CORRECT way to do this. My ideal scenario would be to use a single gpio pin output to light both the LED and sound the buzzer. I can fall back on having to dedicate a separate pin entirely to the buzzer. I DO NOT want to use a physical switch of any kind, or a button on the board. I just want the buzzer to sound when I set the pin to true.

Question #2: why do all the examples I see use pin 1 (3.3v)? Isn't this the same power output as any gpio pin set to true? Why do I see some examples with very high resistors attached to the buzzers? Is it dangerous to hook up my buzzer without one? It seemed to work when I tried it. But again, I want to be correct.

Edit: it seems I need a transistor of sorts (joy, time to drive back to Frys tomorrow). How can I know which one I need? (https://www.sunfounder.com/learn/Super_Kit_V2_for_RaspberryPi/lesson-6-buzzer-super-kit-for-raspberrypi.html)

user2912108
  • 159
  • 1
  • 6
  • I don't know who sunfounder are, but I would suggest using a tutorial from someone who appears to understand electronics; in particular use of an emitter follower is poor design practice. Try https://elinux.org/RPi_GPIO_Interface_Circuits#Output_circuits. Definitely DO NOT connect the published circuit to more than 3.3V. A proper circuit, using NPN transitor can safely be connected to 5V. – Milliways Oct 04 '17 at 02:59
  • Thank you. What if my power source is guaranteed to be no more than 3.3 V? – user2912108 Oct 04 '17 at 03:04
  • The published circuit should work if 3.3V is used, but it is still poor design practice. PS To answer your other question; a LED in parallel with a load is poor design - the LED needs a series resistor, in either case. It is unclear from your question exactly what you are proposing. – Milliways Oct 04 '17 at 03:06

1 Answers1

1

Question #1 is: what is the CORRECT way to do this. My ideal scenario would be to use a single gpio pin output to light both the LED and sound the buzzer. I can fall back on having to dedicate a separate pin entirely to the buzzer. I DO NOT want to use a physical switch of any kind, or a button on the board. I just want the buzzer to sound when I set the pin to true.

It depends on the hardware, specifically on the current that the gpio is capable of give. If the current is not enough, it won't work. The proper (and one of the correct ways) to do this, is hook up a small circuit that uses a transistor or a mosfet.

The gpio will turn "on" the transistor/mosfet by powering the gate pin of the transistor, allowing the current to flow through emitter-collector pins. It will be something like this:

enter image description here

Also, don't forget to put a flyback diode, which is a protection against the inductive current that may appear when switching "off" the transistor/mosfet.

Question #2: why do all the examples I see use pin 1 (3.3v)? Isn't this the same power output as any gpio pin set to true? Why do I see some examples with very high resistors attached to the buzzers? Is it dangerous to hook up my buzzer without one? It seemed to work when I tried it. But again, I want to be correct.

The pin1 (3V3) is a "power supply pin". This means that it will be capable of give all the current that the 3.3V regulator has available. GPIOs have a current limitation, depending on the hardware. Check this to know more about max current per gpio.

About the resistors to the buzzer. Those are current limiter resistors. Those are used to keep current as low as needed and don't burn stuff inside your controller. It might, and probably will work, but you're risking to burn your setup.

Edit: it seems I need a transistor of sorts (joy, time to drive back to Frys tomorrow). How can I know which one I need? (https://www.sunfounder.com/learn/Super_Kit_V2_for_RaspberryPi/lesson-6-buzzer-super-kit-for-raspberrypi.html)

Yes, the best way to do it is to use a transistor. Look for logic level transistors. Probably all the MOSFETs here with 2.7V and lower Vgs "FET Feature" will do the work.

Luis Diaz
  • 483
  • 4
  • 8
  • Thank you. Is the "load" here the buzzer itself? Also is the flyback diode shown in that diagram above? – user2912108 Oct 04 '17 at 20:17
  • Yeah, the load is whatever you want to. No, the flyback diode is not there. You can see it in here https://brenamanf.files.wordpress.com/2014/08/flyback_diode.gif but it's mostly used of inductive loads, but it's always good to have one. – Luis Diaz Oct 05 '17 at 06:13