I can get you the schematic and part numbers on Monday when I’m back at work.
I would appreciate that. I will have to play with that some.
OK, so the other MOSFET I used, which works perfectly with the ESP32's 3.3V logic is the TI CSD18513Q5AT. Like the DMNH4005S, it's a 40V part. But I vaguely recall that the CSD18513Q5AT had higher-voltage siblings in the series. (Edit: the CSD185
31Q5A is 60V and otherwise basically identical.)
The schematic is attached below. Here's how it works:
1. When idle, the capacitor C1 charges to the full DC supply voltage through R1.
2. When CONTROL_IN is driven high, the MOSFET turns on, allowing the solenoid to quickly energize by using the energy stored in C1.
3. While holding, the solenoid is kept at the current limited by R1 and the solenoid's internal DC resistance. C1 stays at the voltage drop across the solenoid.
4. When CONTROL_IN goes low again, the solenoid's energy discharges through D1 and D2.
(Return to 1.)
To use the example of one model of solenoid valve (normally-closed) I used a bunch of these with, the solenoid is rated 24V/100mA. This gives it a DC resistance of 240 ohms. (And power dissipation of 2.4W at full voltage.)
In experimental testing, I found the valve would reliably open at 17V/75mA or above. It would close at 6V/30mA or below. I decided to use a holding current of 50mA.
This means:
R1 = (V
supply/I
hold) - R
dc(solenoid) => R1 = (24V/50mA) - 240Ω = 240Ω
(Yes, when doing a holding current of exactly half, just use a resistor with the same DC resistance as the solenoid.)
The total power dissipated while holding is, of course:
P
hold(total) = V
supply * I
holdof which:
P
hold(solenoid) = (I
hold)
2 * R
dc(solenoid)and
P
hold(R1) = (I
hold)
2 * R1
=> P
hold(solenoid) = (50mA)
2 * 240Ω = 600mW
=> P
hold(R1) = (50mA)
2 * 240Ω = 600mW <-- select the resistor accordingly!
and
=> P
hold(total) = 24V * 50mA = 1.2W
So we've cut the total power dissipation in half, but also divided it between the solenoid and R1.
Determine the size of C1 experimentally. Too small a cap won't work reliably, or may be too slow. It also depends on the cap's ESR. For C1, I used a combination of several tantalums in parallel with a polymer electrolytic. For that solenoid, I used 4x47μF tantalums and a 680μF polymer electrolytic, to ensure enough force to overcome the stickiness of the valve flap after sitting for a while. It's entire application-specific.
Obviously, for significantly larger loads, you'd want a more complex driver that doesn't burn up half the power in a resistor (e.g. by using a separate power rail for the holding voltage, or by using PWM to reduce the holding current). But for small solenoids and relays, this is a simple circuit that is better than nothing, and doesn't require any microcontroller control.