Solenoids on the Arduino with MOSFET power

I am needing to control a solenoid from the Arduino to do some high speed water splash photography. The Solenoid works at 12v and draws up to 2.5w when open, obviously a direct connection to the Arduino is out of the question. Looking in my parts bucket I found an FQP30N06L MOSFET and recalled that I’d used these to control a small motor.

The FQP30N06L MOSFET in a TO-220 package,
the heatsink tab is connected to the Drain

The FQP30N06L is a N-Channel MOSFET and can switch up to 60V DC at 32A, this is more than chunky enough for the solenoid. For use with the Arduino it needs to have ‘logic-level’ switching of 5V, looking at the datasheet for the Static Drain-Source On-Resistance – RDS(on) we can see a test condition where VGS=5V (or 4.5V) exists then we know the MOSFET is suitable.

Looking for logic-level volts in the On Characteristics (source: FQP30N06L datasheet)

The Circuit:

  • D1: 1N4002 Diode – provides surge suppression from the solenoid, this protects the MOSFET from inductive voltage ‘kickback’.
  • L1: the Solenoid or motor (a solenoid is just a linear motor)
  • Q1: FQP30N06L MOSFET being used as a switch
  • R1: 220R Resistor – current limiting, see below.
  • R2: 100K Resistor – this keeps the Gate closed when the Arduino output is off/LOW

The resistor R1 is there to protect the Arduino. On a MOSFET when a voltage is first applied to the Gate it can appear as a short to ground, limiting the current will prevent a surge that may cause damage. The Arduino supplies 5V at 40mA on a digital I/O pin.

A MOSFET switches when there is a charge at the Gate, the higher the charge the wider the gate opens and more current can flow through the Source to the Drain. Looking on the datasheet for our MOSFET the Gate Threshold Voltage VGS(th) shows a minimum of 1V and a maximum of 2.5V, this means that below 1V the gate is closed, at 1V the gate is ajar, as the voltage increases the gate opens wider until you reach 2.5V where it is fully open, power can go above this but the gate will not open any further. Going above 20V on the gate VGS will break the MOSFET.

So we need a resistor low enough to fully open the gates, but high enough to prevent the Arduino spluttering. So I chose to limit the current to 20mA and calculated the resistor with Ohms Law:
R = V / I
5V / 20mA = 250R (I used a 220R as that’s the nearest I had, this limits the current to 23mA)

Ground on the Ardunio is shared with the 12V power supply for the solenoid.


Connect the circuit to your Arduino, the MOFSET’s gate to a digital output and ground. You may want to avoid digital pins 0 and 1 as these are on the serial port and can cause the solenoid to rattle unexpectedly.

Here is the Solenoid equivalent of blink, with the solenoid circuit connected to digital pin 3 it is switched on and off once a second:

Comedy effect can be had by reducing the timings to milliseconds, although keeping that up for too long will probably knacker the solenoid.

Solenoid Control

References and Links:

One thought on “Solenoids on the Arduino with MOSFET power”

  1. What about 270R instead of 220R?
    It will drop abt 19mA from Arduino, making it more “confortable”.
    Also you won’t get too much V decreasing on the FET’s gate.

    Am I wrong??

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.