I want to control a speaker via GPIO to play a square wave of varying frequencies. The first speaker I found laying around my house had 4Ω 10W printed on the back. I know for a fact this is not an ideal speaker for this purpose, but I want to make sure my reasoning below is correct, even if I end up using a different speaker.

First, would hooking the speaker up to, for example, GPIO12(pin 32) and GROUND(pin 30) fry my pi? I don't think it will, but I just want to be safe.

Second, since the GPIO only outputs 3.3V, and the speaker resistance is 4Ω, what is the maximum wattage I should be able to get? Using W=(V^2)/Ω, I calculated a wattage of 2.7225W.

Third, assuming I am correct about the maximum wattage being much lower than 10W, would the speaker just be really quiet? Or would it not work at all?

  • You would be better of starting with a PC piezo speaker. You should have one somewhere? Like inside your PC or get one of eBay for very cheap. The problem with your calculation is that 2.7 watts is about 0.8Amps -- There is no way the GPIO will handle that. Piezo speakers work extremely well with low current applications but the caveat is you cannot generate low tone signals.. (bass in your face) but you can easily generate super sonic sound though!
    – Piotr Kula
    Commented Jan 5, 2017 at 10:30

3 Answers 3


In this case, the power the speaker draws is limited by the GPIO pin's ability to source current, which, if memory serves, is of the order of 10mA. You won't be getting much use out of that speaker; it will look like a short-to-ground to the pin.


A piezo will give you a single tone type buzzer. If you need more tones then you can add a simple transistor buffer to allow your gpio to drive a speaker. Then you can use PWM to make almost any combination of frequencies you'd like. In this image your GPIO would connect to R1. enter image description here

Source: using-a-speaker-for-audio-output

NOTE: You must use a frequency to drive this circuit. If you simply drive the gpio high and leave it, you will still cause a short circuit across your power supply.


The problem with dynamic speakers are that they are directly connected to the coil so they actually need a powerful driving circuit like some kind of amplifier. The other problem is that just connecting this to GPIO is like short circuiting using a very long wire (as JayEye mentioned)

enter image description here

Piezo speakers are what you need to get some sound out of pushing some frequencies through GPIO. Piezo speakers have a built in driver, a very simple one that uses a crystal and when you apply a voltage or wave that driver creates a resonance that drives the tiny coil in the piezo bender causing a metalic plate to vibrate at the frequency applied and producing audible sound. Piezo speakers draw very little current and work exceptionally well at high frequencies.

enter image description here

You can even build your own piezo electric speaker using a crystal, tin foil, tin can and some transformer as demonstrated on hack a day

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.