4

I have this PCB speaker I really would like to mount to my Raspberry Pi model B but I am not sure if I can connect it directly to the 3.3VDC and a GPIO?

As far as I can tell it is from 0.1W to 0.2W as a maximum so can I use the Ohm's law like this: P / U = 0.2W / 3.3V = 0.06 amps * 1000 = 60mA?

I have seen elsewhere that the maximum current on each GPIO is 16mA and that the maximum on all GPIOs is 50mA but am I right in the above assumption? And if it is not possible to directly mount it, what would it then take to mount it through the 5VDC (I assume some resistors)?

0

1 Answer 1

6

What you need is a power amplifier.

8 ohm speaker is essentially a short-circuit for most applications. By connecting it straight to a device that's not a power amplifier you're risking a damage both to the output stage of the driver (since it gets shorted and the power is used on it's internals, not the driven device) and to the speaker itself (if the driver can supply more current than the speaker can bear).

So yes, your calculations are roughly correct, you'd be trying to fry your Pi by connecting it directly. If your Pi has a current limiter (I'm no expert on Pi, mind me, but I'd assume it doesn't), you will just drive your Pi on 100% power output, so it's still a bad idea.

As to connecting it - you can either connect a speaker with a higher resistance (but that will decrease both the current and the power output of the speaker, making it quite quiet), or use a simple transistor to drive the speaker. Googling "transistor amplifier" can give you some ideas how to do it, although the simplest approach is along the lines:

enter image description here

or

http://www.techlib.com/electronics/graphics/classa1.gif

Note that if you're feeling lucky, for testing purposes you can manage with a single transistor and two resistors: put one resistor between GPIO & transistor base to limit base current, for 3.3V & 10mA max on GPIO it'd be around 330 ohm ; plug emitter to ground ; plug your speaker in series with another resistor between Vcc & collector to limit speaker current. 0.1W / 8 ohm speaker can manage about 100mA, so a 33 ohm one should do the trick here.

It usually works nice while breadboarding, YMMV, but it's definitely NOT suited for real audio applications.

3
  • Can I please ask you to delete your answer? I really want to delete my original question as it is not on topic here in SO. Thanks a lot
    – Beauvais
    Commented Dec 11, 2014 at 12:55
  • 1
    @DHS : a) it's me who flagged it as such, and as such, I'm aware of that fact, b) if you consider your question a good one or important one, it should be migrated, not deleted. Simply flag it with moderator comment "please migrate to electronics.stackexchange.com " if you consider so; also, c) if the answer I've given answers your question, simply accept both the answer and the fact that it has been closed - that question shouldn't be migrated, but the answer should stay, as per meta.stackexchange.com/questions/10249/…
    – vaxquis
    Commented Dec 11, 2014 at 13:29
  • I didn't know it was possible to migrate it but this is great as it is much better suited for the Rasberry Pi section which I discovered after this question. To be honest I don't understand your answer as it is too complicated to me - I am no hardware guy and I have dropped my initial idea to have this speaker on my RasPi
    – Beauvais
    Commented Dec 11, 2014 at 15:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.