I'm attempting to control the P-FET by toggling the ESP32 pin IO13 between HIGH and LOW.
However, I'm encountering an issue where the P-FET remains constantly ON, even though I'm changing state of IO13 coz I'm measuring 42V on the terminal block every time
In order to turn off the P-MOSFET, you need to make the gate voltage and source voltage the same.
So if you are using 42V then the gate also needs to be 42V
Do you understand?
However when you turn it on the gate voltage should not be less than 42V-20V = 22V or you will burn out the MOSFET.
You will need a transistor to connect to the MOSFET gate so it can be controlled by the ESP
I prefer the zener version as it guarantees the PFET's gate is protected, but a resistor divider will work too. R2 can be 22k if you only have E12 resistor values...