# I'd like to know if this MOSFET switches design is okay

I have a design where the power of my circuit comes from a 12V battery and I use the energy from the battery to turn on/off a solenoid valve using an ESP32 (which outputs 3.3V from it's GPIO).

In general the circuit will have some other elements that require power from the battery.

The logic of my circuit is as follows: If the battery voltage drops below a certain threshold, disconnect the power of the battery from every other component in the circuit BUT the ESP32 (which has a buck converter that converts 12V -> 3.3V)

Now, to do this, I'm considering using a MOSFET for switching on/off the current flow from the 12V from the battery to the rest of the circuit when this condition is met, I'm adding a flyback schottky diode for safety (because I'll have some inductive loads).

Now, I'm not entirely sure if I should connect the drain of my first MOSFET to the source of the second MOSFET. The second MOSFET will be used to turn on/off the solenoid valve using another GPIO of the ESP32.

I'm sorry if I'm not making myself clear, I'm struggling with my english over here. I'm attaching a schematic that I've been simulating on multisim. The circuit on the left is the switch that cuts off the power from the circuit of the right. The circuit on the right is the one that turns on/off the solenoid valve (modeled as an array of inductances and resistors that I found on research gate)

• Why is there a resistive voltage divider (e.g., R6, R1 and R3, R7) feeding the gate of each MOSFET? If R1 and R7 are intended to be pull-down resistors to keep the MOSFETS in cutoff (turned OFF) when no signal source actively drives a voltage onto the gate of each MOSFET, why not put R1 to the left of R6, and R7 to the left of R3? You get the same result (MOSFETs are OFF by default) without the voltage divider (which unnecessarily complicates matters). Mar 28, 2020 at 21:46

Second, I recommend you use a comparator with hysteresis for your "low battery" detector circuit (Reference1, Reference2, Reference3). Note that a battery's voltage changes for loaded (high current) and unloaded (low or zero current) conditions. Imagine that you choose a voltage of 11.8 VDC as your "low battery" threshold voltage. The battery, when it is connected to its full load, slowly discharges until its terminal voltage dips below 11.8 VDC. Your comparator circuit detects the condition $$\V_{battery} \le V_{threshold}\$$ and your circuit disconnects +12 VDC power from the load, which causes a sudden reduction in output current at the battery, which causes a sudden increase in voltage at the battery's terminals—e.g., perhaps the voltage rises to 11.9 VDC. The comparator (if it DOES NOT have hysteresis) now notices the battery voltage is 11.9 VDC, which is greater than the threshold voltage, and your circuit reconnects the load the +12 VDC supply. Once again, the battery is loaded down, its voltage dips below $$\V_{threshold}\$$, your circuit disconnects +12 VDC power from the load, and so on. At this point the circuit is oscillating, rapidly turning OFF|ON the +12 VDC power to the downstream load, which is bad for the downstream load and for transistors Q1 and Q2.