I'm tring to use a transistor bc337 like a switch beetween a 12V battery and a circuit. the base of the transistor is connect to a esp32 wroom gpio pin, using a resistence of the base of 1.5K. The collector is connect to the VIN- pin of a regulator LM2596, and the emisor of the transistor is connect to the negative terminal of the batteries pack. The positive terminal of the batteries is connect to the VIN+ pin of a regulator LM2596. When I connect the esp32 wroom to the circuit, with the GPIO pin un LOW, the transistor activate
immediately.
When I test the voltaje in the GPIO pin with the esp32 wroom disconnected I'd a voltaje of -8V aprox, and a voltaje of -10V in the emissor.
Hi, I want to help here.
Better to provide a schematics, not a PCB layout ("we do not trace back how you have wired").
I tried to understand your text description. Confusing is:
"The collector is connect to the VIN- pin of a regulator LM2596".
What does it mean? You have grounded the collector? How could it work?
Here my schematics you want to have at the end (for my understanding).
Just check how C (collector), E (emitter) are connected.
For a NPN transistor - very common to use as a digital MCU driver:
the B (base) is driven by an MCU GPIO pin: correct: have a resistor there
the E (emitter) is the common ground: all negative poles go to same ground plane
the C (collector) takes ("switches") the load current: it is still positive, e.g. positive out after voltage regulator. Make sure, the current is limited (not to burn transistor).
But a C (collector) on an NPN transistor connected to GND (VIN-) - cannot work.
For a PNP transistor it would be correct - but you have chosen BC337 as NPN.
You can do a similar logic with a PNP (but the schematics and even the logic changes).