MOSFET Switching Problems


One thing you definitely need is another delay after digitalWrite(valve1,LOW);


ah good catch, but did not fix my issue


I don’t understand what your problem is. In a post you made 7 days ago, you said, "Grounding the data pin has worked!"So what’s changed since then? Didn’t you have it working at that point?


Sorry for the lack of clarity, as I am just frustrated with this circuit.

Grounding the data pin did work initially, but sparingly. Sometimes I would have to unplug the valve then replug it, then it would switch as intended. Other times it wouldn’t switch at all just be open until I unplugged it. I know that it’s something simple and when I get it ill kick myself for stressing this much about it, but in the moment it sucks.

I feel that every change that is suggested works for a few cycles of turning on and off the power supply and/or the photon, but nothing has working consistently? Is their a set of guidelines i should follow?

Thanks for your help, I don’t know what’d i’d do without this forum.

EDIT: here is a picture of the trouble maker, I spread the components out to try and make sure it was all correct, the power supply plugs into the rails that are second closest to the camera.


This sounds like some kind of hardware problem, I think your setup is ok (as far as I can see). What valve are you using?


If by values you mean the values of the components,

Resistor - 220 ohm
Diode - rated for 12V 5W -1N5349B (and no change when its removed)
N-Channel MOSFET - RFP30N06LE

I’ve been moving the circuit and switching the wires out out to try and avoid any sort of contact problem


Values? I asked about the valve you’re using.


Wow, I completely misread that HAHA. Its this one. I have two and have switch them them out periodically also.


The specs for that valve have this statement: “The valve has a gasket arrangement inside, so there is a minimum pressure requirement of 0.02 Mpa (3 PSI)”. I’m not positive what that means, but I think it means the valve needs to be under a minimum pressure to operate properly. Are you testing it when it’s hooked up to a liquid source with at least that minimum pressure, or are you testing it dry?


Thats correct, I have been running it dry. Even when running it dry I can feel and hear the solenoid switching on and off when I had it working initially. I tried blowing the valve when it was open and it did require a little pressure before allowing air through.


I think you need to test it with the proper water pressure applied to it, in order for the test to be meaningful.


I successfully add a Mosfet to Arduino to control power and speed to 3 x 12v high-speed fans. It should also work just fine for your project even if you don’t need to PWM the power to the 12v pumps.

Just ignore the potentiometer in the Arduino schematic, I didn’t use that, just wire the MOSFET up like you see it on the breadboard and pull the Gate PIN high and you should get power flowing to your 12v motor.


I cannot see the 220Ohm resistor but a 10k between D0 and the Gate pin.
The 10k should be between Gate and common ground.
I can’t seem the cap either.

Maybe you replace the valve with an ordinary 12 relay or any other 12V component to check the circuit first.


I removed the cap to troubleshoot the circuit, as the cap serves more the to the opimzation of the ciruit than the overall function. I have been trying each time I wire it up with and without the 10K resistor to see if it works.

The tutorial i found here has neither the cap or the 10k resistor. It also seems that in that tutorial they don’t connect it to water, as there is no mention of it. When I wire it up the way listed in the above link, it switched for a few moments then the solenoid went to a high frequency humming, as if it were switching on and off but not fully coming to a stop, which to mean means noisy signal so i tried the 220ohm and the 10K as mentioned in this post and that change somehow managed to have me measure 0v across the diode. I feel as though i’m chasing a ghost.

ill have to think if I have any 12V components laying around to test the circuit.


I had a problem wiring this one up, when i ignore the potentiometer for which i assume is for PWM I get no power to the diode I appreciate the link it did have a lot of useful information for if i do try and control using PWM


Are you using logic level MOSFETs?


I am using RFP30N06LE 's from everything i’ve seen these are recommended by other arduino and photon makers.


I have a project with four valves that are very similar, and they do not work correctly without water pressure.


As I suggested above, and as @dome has also said, you need to test it under pressure, otherwise you are just wasting your time (and ours). The tutorial you mention above also states this, and that fact is also mentioned several times in the comments. You can’t know if there is something else wrong with your setup or code unless you test the valve under conditions it’s designed for.


Appreciate the input.

I have gotten the circuit to work (without water). I still do not know what the issue was. I am attempting to move this to a soldered board which is where the problem originally manifested itself, so if anyone has any good layout techniques i’m all ears.

Thanks all for your help

Best way to quickly switch AC power