ESP32 Solenoid Control – Driving Solenoid Requiring 2A/24V DC with IRF520

esp32solenoid-valve

I am trying to design a circuit, which will drive my home valves which is on 24V and by specifications must supply 2A ( but this is quite suspicious, and probably it is requiring much lower current, but sill I wish to make it fulfill this requirement ).
I found a few circuits, but when I doublechecked them – most of them ends with an issue.
So, just as a precaution I wish to ask peoples which done this eventually for guide.

  • How to drive IRF520 with ESP32 3.3V output correctly ?

Best Answer

In my experience with 24V solenoid valves, they don't need the maximum listed current. For a 2A solenoid it probably needs 1-1.5A to activate, and then ~500mA to hold open. You can design circuits which supply this.

The listed mosfet has a threshold voltage between 2 and 4 volts, so it's likely the ESP32 can't turn it on from 3.3V. You would want a smaller mosfet to drive the gate on it.

This is a really obnoxious part to design this circuit with, because the gate voltage range is above a microcontroller but it's also below 24v. I would encourage you to get a logic level mosfet if you have the option to. That way you don't need to worry about all of these gate voltage thresholds, and you could use 1 mosfet and 1 resistor.

This is the best I could come up with, it should be compatible with most garden variety p-mosfets and n-mosfets, and a handful of 10k resistors:

schematic

simulate this circuit – Schematic created using CircuitLab

EDIT:

This is how it would simplify with a logic-level mosfet.

schematic

simulate this circuit

Very easy to find a new part with:

  • VDS of greater than 24V, 30 is very common
  • Current rating greater than 2A
  • low RDSon specified between 1.8-4.5V, usually means its logic level
  • VGSth max of 3.3V or less
  • low input capacitance, otherwise put a series resistor