Arduino N-MOSFET Switch and Solenoid

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?

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)


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?

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.

Wawa, thank you, I didn't know that. I found explanation : 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.


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, :slight_smile: :smiley:

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.

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 :wink:

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.

Hi Guys,

I know it has been a minute or two since my last post, but I just wanted to let you all know that I got it to work. I did two things. First, I tried to look into a relay to replace the MOSFET, but I was going to lose the ability to implement some other stuff that I want to add later. I ran across the “FQP30N06L” MOSFET. It’s a bit more BEEFER than the “IRLB8721PbF” MOSFET.

Second, I changed proto Boards. I was using the screw Shield by Adafruit. It is a real nice little shield that I will probably use in other projects. However, for this project, I felt that my problems were caused by micro-shorts. I put the New MOSFET onto the new proto board (which seems to have a little bit larger foot print); and ran 3 wires from the shield to the Gate, Drain, and Source on the new board.
All for my problems (for the moment) have disappeared. Thanks for all of your inputs!!!

Well done.

With mosfets it is normal to switch 1A with a 50A mosfet.
The Rds(on) value is the resistance of the mosfet when turned on. The lower that value, the less heat is generated. It is 35 milli ohm for this new mosfet. Some use mosfets parallel to reduce the heat. Newer mosfets can have a lower value, so if it gets hot, you could replace it with a better one.
This mosfet is turned on with only 3 or 4 volt at the gate, that is perfect to use with an Arduino.