# connecting speaker to microcontroller

Discussion in 'The Projects Forum' started by s3b4k, Nov 8, 2011.

Feb 15, 2010
38
0
2. ### t06afre AAC Fanatic!

May 11, 2009
5,939
1,222
In this case I would perhaps use a 555 timer in ASTABLE configuration. Then tune Tune the 555 frequency to get the loudest output. You could then connect the 555 circuit pin 4 to your controller to turn the sound on/off. How many volt will your power supply be?

3. ### Audioguru New Member

Dec 20, 2007
9,411
896
The spec's for the tiny Chinese speaker does not say the distance where it produces 93dB.
Since its tested input is only 60mV then maybe you must wear it like an earphone to hear 93dB.

4. ### Georacer Moderator

Nov 25, 2009
5,151
1,266
Audioguru, what does the 93dB mark represent? Is it a human hearing threshold?

5. ### PatM Active Member

Dec 31, 2010
81
72
30 Milliwatts doesn't seem to be much of a audio level.

6. ### SgtWookie Expert

Jul 17, 2007
22,183
1,729
I see that it's rated for 30mW, with 50mW being the absolute maximum.
150 Ohms and 30mW means the voltage across it would be ~2.12v.
2.74v across it would exceed the maximum rating of 50mW. You want to stay well under that.

In order to keep the maximum power dissipation down to ~30mW, current needs to be limited to ~14.13mA tops, or as stated above, voltage across it limited to 2.12v.

You could simply subtract 2.12v from your supply voltage, and then divide that result by 14.13mA to determine the resistance you need to add between the speaker and the I/O pin.

Example: Vdd=5v
Rspeaker >= (5v-2.12v)/14.12mA = 2.88/0.01412 = 203.966 Ohms.
In this case, 220 Ohms would add a margin of safety; after all you don't want to damage the speaker.
Double-checking:
5v/(150+220)= 5/370 = 13.51mA; P(Watts)=I(Amperes)^2*R(Ohms), so P= 13.51^2*150 = 27.4mW.

The ATmega8 can sink or source up to 40mA from it's I/O pins, so you're good there.

It would probably be a good idea to use a 1uF cap from the I/O pin to the speaker to block DC from flowing through it.

7. ### Audioguru New Member

Dec 20, 2007
9,411
896
Real speakers have their sound pressure level measured at a distance of 1m and a power of 1W. Most are about 90dB.
93dB is fairly loud. Look in Google to see how loud is a whisper or a closeby jet airplane.

8. ### t06afre AAC Fanatic!

May 11, 2009
5,939
1,222
This device is more a buzzer than speaker. The frequency range is somewhat limeted. 300 to 3.4 KHz. As a small buzzer it might work in a microcontroller setting.

9. ### Audioguru New Member

Dec 20, 2007
9,411
896
An old fashioned telephone had an earpiece that mechanically filtered sounds below 300Hz and above 3kHz. Similar to this little "speaker".