connecting the base to the ground does no good. It makes the voltage constant but it makes it so there is no sound coming from my speaker. Also, removing the .02 cap didn’t work because I believe the npn acts as a highpass filter so removing the cap doesn’t work either.
I’ll try the oversampling.
If I remove the speaker, and leave the negative end of the 10uf (the one in series with the speaker) cap floating, there is a recognizable discharge waveform from the capacitor (measured from an oscilloscope in my lab).
So maybe this waveform is the reason for the random readings on the Arduino?