luarit
Posts: 8
Joined: Fri Jan 24, 2020 4:01 pm

buzzer 3 Pins

Fri Jan 24, 2020 10:07 pm

Hello,

I tried to make sound with a buzzer with 3 PINS. The code is as below. When I ran it it doesnt sound but... I hear like a click every second. Why I cant hear any sound?

Code: Select all

[
import RPi.GPIO as GPIO
import time

buzzPin =11
GPIO.setmode(GPIO.BCM)

try:
  GPIO.setup(buzzPin, GPIO.OUT)
  while True:
    time.sleep(1)
    GPIO.output(buzzPin, GPIO.LOW)
    time.sleep(1)
    GPIO.output(buzzPin, GPIO.HIGH)

except:
  GPIO.cleanup()/code]

User avatar
DougieLawson
Posts: 40564
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: buzzer 3 Pins

Fri Jan 24, 2020 10:33 pm

Have you got the buzzer the right way round. They have a polarity. The anode on the buzzer needs to connect to GPIO11 (pin#23) https://pinout.xyz/pinout/pin23_gpio11

The cathode of the buzzer needs to connect to a ground pin. https://pinout.xyz/pinout/ground
Any language using left-hand whitespace for syntax is ridiculous

Any DMs sent on Twitter will be answered next month.
Fake doctors - are all on my foes list.

Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

User avatar
Burngate
Posts: 6402
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: buzzer 3 Pins

Sat Jan 25, 2020 10:26 am

It might also be useful to post details of your 3-pin buzzer

luarit
Posts: 8
Joined: Fri Jan 24, 2020 4:01 pm

Re: buzzer 3 Pins

Sat Jan 25, 2020 1:01 pm

It is this one

https://es.aliexpress.com/item/32313281738.html

See in the attachment how is connected
WhatsApp Image 2020-01-25 at 10.22.48.jpeg
image
WhatsApp Image 2020-01-25 at 10.22.48.jpeg (180.61 KiB) Viewed 803 times

pcmanbob
Posts: 10485
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: buzzer 3 Pins

Sat Jan 25, 2020 1:14 pm

Well the description seems to be a bit confusing as it can't decide if its a buzzer or a sensor
Low Level Trigger Magnetic Passive Buzzer Alarm Sound Sensor Module
So which is it a buzzer or a sound sensor ?

but it claims
5.When the I / O port input high, the buzzer sound
regardless of all that you have your white wire on the wrong pin , you have it on physical pin 11 but you are using BCM numbering so you want it on gpio 11 which is physical pin 23

Code: Select all

buzzPin =11
GPIO.setmode(GPIO.BCM)
https://pinout.xyz/pinout/pin23_gpio11#
Last edited by pcmanbob on Sat Jan 25, 2020 6:27 pm, edited 1 time in total.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

emma1997
Posts: 1309
Joined: Sun Nov 08, 2015 7:00 pm
Location: New England (not that old one)

Re: buzzer 3 Pins

Sat Jan 25, 2020 5:35 pm

No sensor. In china-talk the word 'passive' denotes speaker transducer only whereas 'active' has built-in tone generator IC. I know this from having purchased thousands of the latter for a client and personally ended up with quite a few speaker type too. No matter what an amazing deal at 3-4 cents ea.

Occasionally there will be bait and switch artists that incorrectly send the cheaper speaker ones. Not too often though and with Ebay Protection you get to keep them for free.

Note that the speaker only type can sort of function as a sound sensor (mic). Just not very good ones compared to piezo or electret.

As usual 'Arduino' PCB modules are a total rip off if you have any DIY capability at all. That transistor is not always needed with modern MCU pin drive. Hence maybe some confusion over Dougie hinting at only two pins which is actually the smarter configuration (IDK about 'cathode' and 'anode' though, lol).

iwkse
Posts: 1
Joined: Sat May 09, 2020 8:23 pm

Re: buzzer 3 Pins

Sat May 09, 2020 8:26 pm

I have exactly the same issue.
I've connected I/0 to pin 4, here that perpetual click and the beep is random.
On a while on/off loop, it can make it randomly one or two times than silence.
No hints?

pcmanbob
Posts: 10485
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: buzzer 3 Pins

Sun May 10, 2020 12:14 pm

iwkse wrote:
Sat May 09, 2020 8:26 pm
I have exactly the same issue.
I've connected I/0 to pin 4, here that perpetual click and the beep is random.
On a while on/off loop, it can make it randomly one or two times than silence.
No hints?
Then I suggest you do what the OP did and post pictures of the buzzer connected to the pi gpio and the code you are using to drive it.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

User avatar
DougieLawson
Posts: 40564
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: buzzer 3 Pins

Sun May 10, 2020 12:40 pm

iwkse wrote:
Sat May 09, 2020 8:26 pm
I have exactly the same issue.
I've connected I/0 to pin 4, here that perpetual click and the beep is random.
On a while on/off loop, it can make it randomly one or two times than silence.
No hints?
You don't have the same problem. It would have been a better idea to start a new thread.

If you mean PIN#4 that's a 5V pin.
If you mean GPIO#4 have you disabled the 1-wire interface on that pin.

https://pinout.xyz/pinout/pin4_5v_power
https://pinout.xyz/pinout/pin7_gpio4
Any language using left-hand whitespace for syntax is ridiculous

Any DMs sent on Twitter will be answered next month.
Fake doctors - are all on my foes list.

Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Return to “Beginners”