I need to be able to have physical mute for a speaker via a switch, and I need to be able to detect the switch's position via GPIO inputs, so I can't just hook the switch up directly to the speaker. I got the idea to use a button with 3 outputs: 1) GPIO in on raspi 2) 2 transistors to open power to the 2 speakers when the switch is high. I got this transistor idea from a peristaltic pump project, driving the pump with 12v, activated by GPIO, following the bottom schematic here; this had turned out great!

So I adapted my old circuit as such with one speaker, omitting the GPIO input for nowenter image description here

The line out is coming from this pi hat, driving a 5W 8-ohm speaker. The diode is a 1N4007, to prevent back emf, and the transistor is N2222A (note this has a max current of 800 mA which I think I would barely stay under with a 5W 8-ohm speaker). The resistor is 2.2 kOhms, and I'm using a pi zero W.

Anyway, it works great! Holding the button activates the speaker, letting go deactivates. However, the issue is my pi is getting blazingly hot ... scalding actually, within minutes of turning on when hooked up like this; I think it's the CPU. I have a feeling something isn't quite right, I've probably committed some kind of circuit treason, drawing way too much current somewhere and lucky my pi isn't fried. What would be the issue?

Once this circuit is working, I'd want to hook up a second wire on row 10 to a GPIO pin, with a pull-down, so when the switch is hit it reads high, ie it is unmuted. I also want to hook up the third wire on row 10 to a second transistor setup for the second speaker. I'm learning all this slowly, I've taken a year of physics in college but that's about it. Thanks for all the help.

1 Answer 1


Get a DPST or 3PST switch. Use one pole to disconnect the amplifier (or two poles to disconnect the speakers). Use the remaining pole for a GPIO input to detect the state of the switch.

Your RPi is probably getting hot because you're using its 3.3V to power your schematic, and you're drawing way too much power. Use 5V instead.

  • Thanks! Sounds like a 3PST is exactly what I need, question is where to buy one. Now with the current schematic, I guess I'm not understanding where the power is coming from when the button is not pressed! When not pressed, there is no current flowing anywhere in the circuit except to the right speaker, yet the pi still turns hot. I'm using a 2.2 kOhm resistor so it should only pull 1.5 mA from the 3.3 V rail when the button is pressed. Now I did blow that right speaker at some point during this, is that what's getting the extra current in some way?
    – VarBird
    Feb 11, 2020 at 18:30
  • You can easily get a 3PST switch from mouser if you don't mind paying $10 for it. It will likely be cheaper on Aliexpress or in your local electronics store. Concerning the current, if that resistor really is 2.2 kOhm, it should indeed limit the current to a safe level. Actually with 3.3*1.5 = 5 mW of power provided to a 5W speaker you wouldn't hear anything from it. Perhaps your circuit is not what you think it is. Maybe you should buy a pre-built amplifier (e.g. PAM-8403) while you shop for the switch. Feb 12, 2020 at 8:27

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.