Easiest method of adding a beeper to the Pi


14 posts
by precious_pony » Fri Nov 23, 2012 2:30 am
Hello,

I'm a software guy really, and electronics has always confused me, so I thought I'd ask in here about the possibility of adding a beeper to the raspberry pi via GPIO.

I have a couple of Pi's, one 512MB, and one 256MB.

My 256MB is running some custom-written monitoring software, and upon the triggering of certain conditions, it sends out an email and optionally a tweet. Trouble is, I receive lots of emails during the day, so I constantly have to check every email as soon as it arrives when the Pi doing the monitoring is right next to me.

For this reason, I would like the Pi itself to beep in order for the Pi itself to be a literal alarm.

I wonder if someone can tell me if its possible, and what components I might require in order to achieve this.

I've found this buzzer:

http://www.tandyonline.co.uk/miniature-3-3v-pcb-buzzer.html

Now, will I require other components (such as capacitors/resistors), and what is the best method to connect to the GPIO pins themselves?

Apologies if this is hellishly amateurish, I'm a hellish hardware amateur.

PP
Posts: 28
Joined: Tue May 22, 2012 11:09 pm
by joan » Fri Nov 23, 2012 8:52 am
I don't know but it might have been covered by the magpi magazine. Free on-line at http://www.themagpi.com/
User avatar
Posts: 5983
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK
by malakai » Fri Nov 23, 2012 9:01 am
http://www.raspians.com - always looking for content feel free to ask to have it posted. Or sign up and message me to become a contributor to the site. Raspians is not affiliated with the Raspberry Pi Foundation. (RPi's + You = Raspians)
User avatar
Posts: 1383
Joined: Sat Sep 15, 2012 10:35 am
by poing » Fri Nov 23, 2012 9:57 am
That looks cool, just what I need. Any chance that little board is for sale somewhere? Can't find it anywhere, just the tutorial on how to use it :?
Posts: 1097
Joined: Thu Mar 08, 2012 3:32 pm
by mahjongg » Fri Nov 23, 2012 10:09 am
precious_pony wrote:
I've found this buzzer:

http://www.tandyonline.co.uk/miniature-3-3v-pcb-buzzer.html

Now, will I require other components (such as capacitors/resistors), and what is the best method to connect to the GPIO pins themselves?

PP

No its piezoelectric, so you can directly connect it between a GPIO pin and GND. But you cannot simply turn it on and off, you actually have to send a stream of zeros and ones to it at an audible rate! Also, with just a 3V3 square wave signal it will be very quiet, you can improve that a bit by connecting it in-between two pins and making one pin high while making the other pin low and vice versa.
User avatar
Forum Moderator
Forum Moderator
Posts: 5692
Joined: Sun Mar 11, 2012 12:19 am
by MattHawkinsUK » Fri Nov 23, 2012 10:16 am
I sold some of those boards on eBay last week. I'm waiting for some more PCBs to arrive (eta 1 week hopefully).

The buzzer I use is a small 5V device. It has a built in oscillator so it will make a noise just by connecting it to 5V. I am using one in my garage monitoring system. Because it is so small it is not very loud. Fine for experimenting and audible notifications but not really suitable for frightening burglars.
My Raspberry Pi blog and home of the BerryClip Add-on board : http://www.raspberrypi-spy.co.uk/
Follow me on Google+, Facebook, Pinterest and Twitter (@RPiSpy)
User avatar
Posts: 491
Joined: Tue Jan 10, 2012 8:48 pm
Location: UK
by Burngate » Fri Nov 23, 2012 11:10 am
mahjongg wrote:
precious_pony wrote:
I've found this buzzer:

http://www.tandyonline.co.uk/miniature-3-3v-pcb-buzzer.html

Now, will I require other components (such as capacitors/resistors), and what is the best method to connect to the GPIO pins themselves?

PP

No its piezoelectric, so you can directly connect it between a GPIO pin and GND. But you cannot simply turn it on and off, you actually have to send a stream of zeros and ones to it at an audible rate! Also, with just a 3V3 square wave signal it will be very quiet, you can improve that a bit by connecting it in-between two pins and making one pin high while making the other pin low and vice versa.

My reading of that page is that it's a buzzer - connect 3v3 to it and it buzzes.
It mentions 2.3KHz. It couldn't do that if it needs pulses
Also, I used something similar 20ya, and it just took 5v and buzzed

The only thing I would say is it takes 30mA, so you might need to up the GPIO drive
Wyszkowski's Second Law: Anything can be made to work if you fiddle with it long enough.
Brain surgery is easier than psychoanalysis
User avatar
Posts: 2903
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK
by poing » Fri Nov 23, 2012 12:05 pm
MattHawkinsUK wrote:I sold some of those boards on eBay last week. I'm waiting for some more PCBs to arrive (eta 1 week hopefully).

The buzzer I use is a small 5V device. It has a built in oscillator so it will make a noise just by connecting it to 5V. I am using one in my garage monitoring system. Because it is so small it is not very loud. Fine for experimenting and audible notifications but not really suitable for frightening burglars.


OK, let me know if you please.
Posts: 1097
Joined: Thu Mar 08, 2012 3:32 pm
by mahjongg » Fri Nov 23, 2012 2:52 pm
Burngate wrote:It mentions 2.3KHz. It couldn't do that if it needs pulses
Also, I used something similar 20ya, and it just took 5v and buzzed

The only thing I would say is it takes 30mA, so you might need to up the GPIO drive

Mentioning a frequency doesn't have to mean it includes electronics, it could also be its resonant frequency, the frequency that sounds the loudest when you send pulses to it at that frequency.
Actually it's more the 30mA that makes me believe it really has a a stable miltivibrator inside, as piezo buzzers themselves consume less than 1mA, even when resonating at their resonant frequency.
Most devices in this for that I have seen do not have electronics built in, they are just "speakers", either piezoelectric or electromechanical. the real buffer type are more often rectangular with two wires. like this one Image
For such a device, you need a transistor (and a base-resistor) to turn it on an off.
User avatar
Forum Moderator
Forum Moderator
Posts: 5692
Joined: Sun Mar 11, 2012 12:19 am
by gordon@drogon.net » Fri Nov 23, 2012 11:26 pm
mahjongg wrote:
precious_pony wrote:
I've found this buzzer:

http://www.tandyonline.co.uk/miniature-3-3v-pcb-buzzer.html

Now, will I require other components (such as capacitors/resistors), and what is the best method to connect to the GPIO pins themselves?

PP

No its piezoelectric, so you can directly connect it between a GPIO pin and GND. But you cannot simply turn it on and off, you actually have to send a stream of zeros and ones to it at an audible rate! Also, with just a 3V3 square wave signal it will be very quiet, you can improve that a bit by connecting it in-between two pins and making one pin high while making the other pin low and vice versa.


I don't know abou the tandy one, but the standard flat-disc piezeo buzzers are quite loud when connected from a GPIO line to 0v - louder still when connected across 2 GPIO lines an driven in push-pull mode... They're even louder when you fix them to a solid surface (which IIRC you're supposed to do anyway). I've also been experimenting with connecting a 64Ω speaker to a GPIO output too - that's quite loud too...

I have a modified version of my softwarePWM driver to send tones to it... It's a bit "Apple II" in quality, but it can certianly produce some good beeps and squawks...


-Gordon
--
Gordons projects: https://projects.drogon.net/
User avatar
Posts: 1537
Joined: Tue Feb 07, 2012 2:14 pm
Location: Devon, UK
by jojopi » Sat Nov 24, 2012 12:03 am
User avatar
Posts: 2122
Joined: Tue Oct 11, 2011 8:38 pm
by Tandy » Sat Nov 24, 2012 11:05 am
The 3.3V Buzzer makes a sound when connected to a 3.3V supply. There is an example of using it with the Pi in issue 4 of the MagPi.

It can be a bit confusing but generally speaking if you see a part described as a Piezo Transducer or Element then it will not have its own oscilator to make a buzzing sound and will either need an external oscilator circuit or to be driven by pulsing an IO. If it is described as a Piezo Buzzer or Sounder then it has its own oscilator to make a noise of its own.
Tandy - The home of electronics - www.tandyonline.co.uk
User avatar
Posts: 39
Joined: Wed Jun 13, 2012 5:27 pm
Location: Oxford
by precious_pony » Sun Nov 25, 2012 12:50 pm
Thanks for all the suggestions and links.

In the end, I followed the simple approach and used some old USB-powered speakers:

http://www.amazon.co.uk/AIO-3-5mm-Channel-Multimedia-Speakers/dp/B0079JDHLE

I was worried that there may not be enough juice in the USB sockets for the alarm to be loud enough, but it works and seems loud enough for my purposes.

I'm using Java to play the alarm sound, and it seems to work fine.

I would like to actually wire one of the buzzers to the GPIO pins but I'm an absolute beginner and I would need a list of components and a video to attempt such a thing. I'm not even sure if I require some resister/capacitor and what kind of connectors connect to the pins (whether I need something like a full ribbon cable, or some kind of per-pin connector that has a dangling wire.

I'd love the most basic of basic beeper tutorials .
Posts: 28
Joined: Tue May 22, 2012 11:09 pm
by poing » Fri Nov 30, 2012 3:43 pm
MattHawkinsUK wrote:I sold some of those boards on eBay last week. I'm waiting for some more PCBs to arrive (eta 1 week hopefully).


Found them, but you're selling them to UK only :(

Any chance of sending one to Holland (could not find a way to contact you on ebay)?
Posts: 1097
Joined: Thu Mar 08, 2012 3:32 pm