General Circuit Solenoid Question

I am putting together a DIY automatic valve by using this sensor to control this valve.

I know that I will not be able to drive the solenoid with the sensor so I got this Mosfet to help. I plan on using a generic wall wart to power both the sensor and the mosfet (in turn powering the solenoid).

Several questions to make sure I am doing this right:
I also ordered some diodes, are these needed? I would just place one in serial with the signal going to the mosfet?
Is there an easier way to do this?
See any problems with my setup?

I think you have everything you need. I sketched up a circuit for it, using the MOSFET as a low side switch.

SW1 is the liquid sensor.
SW2 is the valve.
D1 is the diode.
U1 is the MOSFET (which includes an internal diode between the drain and source).
R1 is a pull down resistor to pull the gate voltage to ground if the sensor is removed (~10k).

With this setup, the MOSFET should be on when the liquid sensor is dry (opening the valve), and off when the sensor is wet.

The diode across the valve is to protect the rest of the circuit from the EMF created by the relay in the valve, since it is an inductive load. Hope this helps.


Am I understanding correctly that I would only need R1 to prevent issues with disconnecting the sensor? If so I believe I can skip it as I don’t expect this setup to change

A good resource: http://http://hades.mech.northwestern.edu/index.php/Driving_using_a_single_MOSFET

R1 here is good practice, and is a safeguard for if the switch fails.

Is there a reason why you are sinking the valve and not sourcing it?

is there a reason you are not just using a float switch like this one?

Exactly. R1 is there because the gate has a slight capacitance. With the sensor connected, that doesn’t factor in as much, since the sensor outputs a HIGH or LOW. If the gate was left floating (i.e. the sensor output is disconnected from the gate), the voltage at the gate would remain at whatever level it was before the wire was disconnected, which could leave it permanently on. The resistor is there to discharge the capacitance and bring the gate voltage down to 0V.

True, not necessary but good practice. You never know when the switch may be missing (replacing it, installing it, all during prototype/testing) 10k would work. Also not necessary but good practice would be a 10-100 ohm between the gate and the switch depending on the FET.

Also make sure the voltage you’re applying to the gate doesn’t violate the maximum gate voltage of the FET.

I assumed that this was the MOSFET in question, and putting it on the low side was the first thing to come to mind. I thought of suggesting a P-channel MOSFET as a high side switch, but then the logic would be reversed (the valve would be closed while dry and open while wet).

I have had bad luck with float sensors before but in this application that probably would have been a fine choice.

I will add the resistor.

Yeah, I was thinking P-Channel. From a user safety point of view … especially with liquids involved … I prefer to have as little of the circuit energized as possible, until needed.

Also, with that Mosfet, you might want to add a .1 ohm resistor between the V+ and the valve, as the max current on the FET is 62 Amps which at 12V is .193 ohms. The Mosfet RDS(on) is .089 ohms and I’m assuming the valve coil impedance will drop below .1 ohm. This assumes you are leaving it on for some time and aren’t using any pick-and-hold circuitry.

What supply voltage are you intending to use? The solenoid seems to be rated for use with supply voltages from 6 V up to 12 V so you would probably want to stay in that range.

Why is the 0.1 Ohm resistor necessary?

The resistance of the solenoid coil is somewhere around 4 Ohm (= 12 V / 3 A) and will limit the current to well under 62 A with anything under a 12 V supply. With a 12 V supply causing 3 A of coil current to flow, the power dissipated in the MOSFET will be 0.801 Watts, maximum. The MOSFET has a TO-220 case which is generally good for 2-3 Watts, continuous, without a heatsink so you should be good to go.

Since the solenoid limits the supply voltage to 12 V or less, not a lot will happen if there is a short between the supply and the fluid. Safety regulations such as those from UL and IEC (CE) don’t worry about anything below 50 V. Little will be gained by using a P-channel MOSFET. There are fewer P-channel MOSFETs available, they generally cost more and have higher on resistance than N-channel devices.

I was planning on using the one in the picture attached. I am now however worried that it would not have enough current based on this chart. I will have to go back downstairs and rummage through the land of misfit power supplys.


You are better off using a 6 Vdc supply since the solenoid coil current is half what it is at 12 V. That means the power at 6 V is 1/4 what it is at 12 V.

The 12 V wall wart in your picture does not have any fuse. It might have some overcurrent detection circuitry and shut itself down in a well-behaved manner. If it is a simple transformer and rectifier, a 100% overload over the 1.5 A rating might not cause it let out the magic smoke immediately. It might then just cook for a while before catching fire.

More than likely it has a PTC on the output.

I didn’t see the coil resistance, and just assumed (foolish me) that it was much lower than that.

None of the wall warts with only a transformer and rectifier that I have taken apart have any sort of protection devices. Please remember that these things are built down to a price. A very low price.

Often, relay and solenoid coil spec sheets only give voltage and current and let the user calculate the resistance. Some give all three.

Correct, which is why I don’t expect it to fold back (over current protection).

But since it does have CSA, I’d expect it not to start a camp fire.

Only one sample has to pass the tests required by the safety certifying body. Unless major changes are made in the design or construction of the device, re-testing is not generally necessary. They will also generally test such a device with the output shorted and the test is likely to be over in a short time. A 100% overload can cause quite a different result and will likely take longer to stabilize or end leading to many more possible failure modes.

In general, running something at 100% overload, continuously is a bad idea. The manufacturer put the spec on there for a reason. For items built down to a price like these wall warts, those specs are also probably optimistic.