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: 37069
Joined: Sun Jun 16, 2013 11:19 pm
Location: 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
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

User avatar
Burngate
Posts: 6181
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 172 times

pcmanbob
Posts: 7916
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: 483
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).

Return to “Beginners”