Go Down

Topic: Arduino N-MOSFET Switch and Solenoid (Read 8647 times) previous topic - next topic


This has worked a few times, now it keeps failing.  I am using a Ford trunk latch solenoid, IRL 8721 (n MOSFET), 1n4001 diode as a flywheel, and the Arduino UNO (pin 7) to drive MOSFET. I have put the circuit a Adafruit screw shield board (it's a proto board with screw blocks).  The schematics of this circuit can be viewed at this Link.  The solenoid works at 12VDC @ 5A.
I put it together, in a project box. I hooked up the solenoid, and tested it. IT Worked!  I unhooked the solenoid, to work on some other mechanical stuff. Hours later, I hooked it back up, and NOTHING! MOSFET was gone (12V across DS when Gate is off.) I replace Fet, connected solenoid turned on Arduino and it worked. I Disconnected and reconnected Solenoid (while the power is OFF), and when I power up, BLAMM- I Got nothing-MOSFET is gone. I have checked for shorts, and found 1; and the problem continues. I have lost 7 MOSFE.

There is one thing that could be adding to the problem, that I have kind of ruled out. When I turn on the Arduino, it automatically cycles through one loop of the program. When I first started this project the Arduino would cycle through on power up, and the MOSFET stayed good.
Any one got a solution?


Jun 28, 2015, 04:28 pm Last Edit: Jun 28, 2015, 04:29 pm by LarryD
Is your 1N4001 still OK?
This circuit is what I normally use in Auto applications (the BJT will invert the logic).
Use a logic mosfet of course (IRL)

No technical PMs.
If you are asked a question, please respond with an answer.
If you are asked for more information, please supply it.
If you need clarification, ask for help.


I can't find an IRL8721, they are IRL'U'8721 or IRL'R'8721 or other, so I assume they are the same.
They are only 30V, a strong voltage peak could destroy it.

If you don't use a resistor from Arduino output to the gate, the mosfet switches at the fastest possible speed with the 40mA of the Arduino filling or emptying the gate. The flyback diode is a very slow 1N4001 (only 50V) rectifier diode. In theory the diode is too slow.
If the solenoid is 5A, then the diode must be able to get a peak of 5A, and should be the same speed as the mosfet.

Perhaps you need a snubber circuit. With long wires and high currents, many things can go wrong.
Do you know how the ground current is going ? It should never go through the Arduino.

My suggestion : If you are not sure about ground currents, use a optocoupler. I use 470 ohm (150 ohm to 1k) for Arduino output to gate, and 10k pulldown resistor before the 470 ohm (at the Arduino side). Use a fast flyback diode for at least 5A peak current. Use a mosfet and diode for higher voltages.


FET's are very sensitive to any spikes on the gate.

not sure how you connect and disconnect your FET, but you might want to pull it to ground at the FET, disconnect, reconnect, then remove the connection to ground.

that might eliminate any static electricity from the equation.

the opto would do pretty much the same thing if you keep the opto connected to the FET and not keep it on the Arduino.


WOW, thanks guys.

LarryD, I thought that my wiring my be wrong, but I have check it repeatedly. So far , so good. I have also changed the 1N4001 for each of the last 4 MOSFET failures.  

Peter_n , My apologies, the correct call out for the MOSFET is IRLB8721PBF (International Rectifier) Data Sheet .
I think that I am good on the ground current. And you Probably right because I do have some long wires.
What diode would you recommend?

Dave-in nj, do you mean, disconnect powers source from circuit before disconnecting solenoid?


Jun 29, 2015, 12:44 am Last Edit: Jun 29, 2015, 12:48 am by Wawa
The flyback diode is a very slow 1N4001 (only 50V) rectifier diode. In theory the diode is too slow.
Common misunderstanding.
1N4001-1N4004 diodes are very fast. as fast as any schottky diode.
That is, the turn-ON time....
You usually can't find that in datasheets.
Those diodes turn OFF slow, but that's not important here.

@LarryD. The circuit in post#1 does NOT need a logic fet, since there is 12volt available for the gate.

@OP. It seems you're doing the right thing.
Using a logic fet.
Diode from +12volt to drain (cathode to +12).
Bleed resistor from gate to ground (10K)
Add a 220ohm between Arduino pin and gate.
You could add a 24volt/1watt zener diode (or a TVS diode) across the mosfet if you think that supply spikes are the problem.


Jun 29, 2015, 01:11 am Last Edit: Jun 29, 2015, 01:12 am by Peter_n
Wawa, thank you, I didn't know that. I found explanation : http://www.cliftonlaboratories.com/diode_turn-on_time.htm. Very interesting.
On that page, the diode is called "inductive snubber diode", but I think the term "flyback diode" is more often used.

So I can use my 1N4007 as flyback diodes without problem.
Only for a high frequency switching power supply (100kHz for example) I need fast (Schottky) diodes. I have a Geiger Counter with full bridge rectifier on the high voltage side. With 1000V fast diodes the DC high voltage was a lot higher than with 1N4007.

Techno-quest, A snubber circuit (capacitor plus resistor in series) might reduce some spikes. When 5A is going through wires, any wire is an inductance and might cause spikes. I would not use 50V components for the diode and the mosfet.

Do you know what is damaged ? The Gate or the Drain-Source path ?
I still wonder if your ground is okay. The slightest ground problem could damaged the mosfet when 5A is going through wires and the ground.

At least a resistor from Arduino output to the Gate will slow down the slope a little, and reduce crazy spikes.
The protection zener or transient voltage suppressor next to the mosfet is good, since you lost enough mosfets already.


The 4005-4007 has a slightly longer turn-on time than the 4001-4004 (linked article).
So the common 1N4004 is usually a good choice for relays and solenoids.


Years ago we standardized on using 1N4007s.
Installed over 15,000 diodes on motorized switches, contactors, solonoids and relays.
To my knowledge not one has failed.

No technical PMs.
If you are asked a question, please respond with an answer.
If you are asked for more information, please supply it.
If you need clarification, ask for help.


As you may have read in that article, the 1-4 is constructed differently from the 5-7.
The turn-on difference is only small, so no real practical differences between using one or the other.


Hay Guys,

When I grow up, I want to be like you guys; like smart and stuff, :) :D  

Just want to let you all Know, that I added a 555Ohm resister on the output pin to the Mosfet gate, with a pull down resister. I tested the unit and installed it, and it kept working. However, I have made a few new observations. 1) My solenoid response time has slowed down. At first, after power up cycle, the solenoid would not come on. The next 3 to 5 cycles, the solenoid comes on real slow. After that, all other cycles, the solenoid works like a champ.
                    2) After reading about the long wire, I ran another current check on the Solenoid. That thing is pulling 8.3A @ 12VDC. The solenoid will only be on for 2.5 seconds at a time, and that MOSFET got HOT fast.

Hay Peter
Are you saying that 50V components are over kill or not enough? What would you use?  


That amount of current....

I would let the Arduino switch a small relay, and let the relay contact switch the solenoid.


I would prefer components for higher voltages.

According to the datasheet : RDSon = 13 milli ohm (half of that with a higher gate voltage).
8.3A through 13 milli ohm... that is 0.1V and 0.9 Watt.
Without a heatsink it can turn hot.

What is the value of the resistor from Gate to GND ? That lowers the Gate voltage. That is why I prefer to put that resistor on the Arduino side of the gate resistor.

To switch 8.3A you really have to know what you are doing. The solenoids turning on real slow or not at all is very bad. Something is wrong. Could you ask someone to check your circuit and wiring ?

I would use a optocoupter (and switch the mosfet gate with higher voltage). Or as Wawa wrote: use a relay. A relay solves all the trouble at once. You need a transistor to turn on the relay.


The solenoids turning on real slow or not at all is very bad. Something is wrong.
I agree with you. I concerned that I have damaged the Arduino from previous trials.
Pin 7 is a digital output (0V to 5V). Currently with no load, I get 3.3V.
The value of the resistor from Gate to GND is 10K. Perhaps I should drop the buffering resister from 555 ohms to 220 ohms. Currently, this is what I have  Photo; accept R1 is 555Ohm and R2 is 10K.

I already have plans to add a solid state relay to this circuit to handle an A/C device.  It draws a min of 16mA (18 to 20mA realistically). Another relay may put me too close to the 40mA limit.  However, I may not have a choice.


Jun 29, 2015, 05:14 pm Last Edit: Jun 29, 2015, 05:14 pm by Peter_n
At this point, I think that making it work is more important. Use a relay or solid state relay. A mosfet can be version 2  ;)

10k/(10k+555) * 5V = 4.73V.
If you power your Arduino board only with USB and that is 4.5V, the Gate voltage could be lowered to 4.26V.That means with 555 ohm and 10k and Arduino 5V output (with a good Arduino board !) the Gate voltage is 4.7V (or 4.26V). That makes a difference for your mosfet. That is why I sometimes connect the 10k to the Arduino output, so the Gate gets 5.0V via the resistor.

Go Up