Protecting my ESP32 from overvoltage on the gate pin of a N-Channel MOSFET

Hi There
I have a N-Channel MOSFET that controls a relay.
Simply put : how can I protect my ESP32 pin from over-voltage if the polarity of the battery is switched?


In this first schematic, the power is connected normally and everything should work fine.

In this second schematic the power is reversed, the diode prevents current flow through the MOSFET.
However the voltage on the GATE1 Pin will now be 28V.
This pin is directly connected to my ESP32 and I fear this will destroy the ESP32.

So how can I prevent this from happening?

Put a diode in series with the 28V power lead.

The voltage will still be 28V on the other side of the diode

At least try to make some sense.

Well of course you can't apply 28V to the GPIO pin. But the second circuit doesn't work. Even if you used a P-channel mosfet as you should for high side switching, high side switching will always present the GPIO problem if the voltage being switched is higher than the Vcc of the processor. If you want high-side switching, you would need to use an NPN transistor or an N-channel mosfet to drive the gate of the main P-channel mosfet.

But why don't you just use the first circuit?

I'm trying to make sense of what you are saying, putting a diode where you suggested would result in no current flowing, the voltage however will still pass through the diode.

This is a case of reverse polarity, so that obviously means that there is no ground to pull the voltage down, thus meaning that the voltage will still remain 28V on the pin connected to the ESP32

If you like I can simulate it for you and you can have a look for yourself

This is what most people do. I don't understand your difficulty with the idea.
If the battery is reversed, no damage.

Capture

I am using the first circuit, the second circuit is just showing how things would look if the polarity was switched, say for example by connecting the power source incorrectly.

the issue lies at the MOSFET side of the circuit, I am talking about a accidental reverse polarity connection.


As shown here, the 2 28V NETs are supposed to be GND, but in the case of reverse polarity, they will be +28V.

The issue is that GATE1 NET is connected to the ESP32, in this case (the reverse polarity) that pin would now have 28V on it

So am I, and the diode solves the problem. "Rest of circuit" includes the MOSFET.

You are just confusing yourself, and posting incorrect schematic diagrams is not helping.

Capture

I added a diode as you suggested.


Please read
In the above simulation, the battery is connected correctly. As you can see the wire in the plot view is the GATE1 NET. At normal operation this voltage is 0V when I am not applying a signal with the ESP32.

NOW, in this simulation, the polarity is reversed. As you can see, the wire in the plot is now 28V and this is the GATE1 NET.

The diode does nothing.
Maybe I am again not understanding you, but this does not solve the problem.

The diode works for everybody else, so try it and see.

You certainly are managing to confuse yourself with those weird schematics.

I give up, but wish you good luck with your project.

Well thanks for nothing i guess

Just eliminate the 100K resistor.
Why is it there?

The 100k resistor basically just pulls the gate down to 0V if no signal is applied, to eliminate any stray signals or floating voltages that might trigger the MOSFET to turn on unwantedly.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.