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 now
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.