BJT and MOSFET switching immediately after receiving power

Hi,
I am building a security system with a 12v piezo buzzer as the alarm. The buzzer is powered through a 555 timer circuit connected directly to 12v however all the other circuit elements are connected to power through a 7805 voltage regulator. The ground pin of the buzzer goes through a 2n2222a bjt transistor with the base connected to pin 23 on an ESP32. I have tested the voltage across the ESP32 and it is 5v, which is the power supply it expected as it can be powered through USB and has an onboard voltage regulator. However, the bjt switches as soon as I switch in the power. I have tested the voltage across the buzzer as soon as the power is turned on and it is 2-3v compared to 8v (not 12v as voltage drop from 555 timer) when the buzzer is triggered through intentional means. I have also tried a base resistor and an Nchannel MOSFET to no avail. Any ideas as the transistor seems to be allowing a connection to ground to the buzzer even when it has not been switched via pin 23 on the ESP32?

A picture paints a thousand words... got a schematic?

quite big would take rtime to draw

I'll start drawing the schematic and post when finished.

finished the schematic!

BJTs require a base resistor.

Mixing 5V and 3V3 is a bad idea.

ok so why does it work with 9v but not with 12v when everything except the buzzer gets the same voltage? it works perfectly with 9?

I don't understand why there is a 555 timer, it is trivial to do the timing in software.

yeah i tried that many times but it didn't work so i just went for the 555

Well we are here to help...

ok but im not sure thats the priority at the moment. all im trying to do now is get my bjt or mosfet to switch the buzzer properly

Put the resistor in, without it you will damage the output circuit of the pin, you might have damaged it already, that might be your problem. Try a different pin. Maybe 220R should be OK.

I've re read your description, what is the voltage across the collector emitter of the BJT when it is on? What is the base voltage?

i have tried several different transistors, but with a 10k base resistor. is 10k too much?

10k is way beyond too much! See previous reply.

How much current does the buzzer draw?

not much

i have 270r will they work?

270R okay.

What are you doing with circuit Q1 and Q2 ?


EDIT

What is signal RFIN doing ?

Wrong answer. Try again. (Hint, your answer should be a number)

(It's 23:27 in the UK, bed time for me)

rfin goes to pin 23 on esp32. the esp32 then triggers the alarm

So 5V on the emitter of Q2 to base to ESP32 pin 17 to anode of input protection diode to 3V3.

Good way to blow the input :thinking:


CMOS output VT to base of Q1 emitter to +5V, how does that work ?