I was wondering what the best way to run a solenoid would be from an Arduino board. I was thinking about using a MOSFET that runs into a relay to turn on the solenoid but am not sure how to go about it.


2 Answers 2


You can drive the solenoid using only the MOSFET (or a bipolar transistor)
It would help to know what type of solenoid you wish to drive so we can select suitable components. Here are a couple of circuits to give you the general idea for MOSFET/Bipolar:

MOSFET solenoid

The resistor can be ~10k - 100k (the range can be wider as Steven notes, e.g. 1k\$ \Omega \$ - 10M\$ \Omega \$ - too high a resistance and you risk susceptibility to noise though), it's to make sure the gate is pulled to ground if the input is floating. The diode can be almost any general purpose diode capable of handling a reasonable amount of current.

Darlington Version:

Darlington solenoid

  • \$\begingroup\$ Oli, I don't think noise will be an issue. Even when driven from an open drain output the pull-up will provide a low impedance. The resistor is just there in case the gate would float for some reason, but if the driver is disconnected/defective the device won't work properly anyway, and by the way, a 10 M\$\Omega\$ resistor generates only 400 \$\mu\$V Johnson noise at room temperature over a 1 MHz bandwidth. \$\endgroup\$
    – stevenvh
    Commented Jul 11, 2012 at 9:57
  • \$\begingroup\$ @Steven - I wasn't thinking of Johnson noise, rather just in the (unlikely) event the input is left floating in a noisy environment (as mentioned). You could say the resistor is not needed at all if you're sure it's always driven properly (e.g. uC pin active before solenoid supply active) \$\endgroup\$
    – Oli Glaser
    Commented Jul 11, 2012 at 10:04
  • \$\begingroup\$ Agreed, and IMO initializing I/Os should be (one of) the first thing to do after the uC is reset. Leaving the gate floating for a ms won't hurt it (even when the solenoid's power is already active). \$\endgroup\$
    – stevenvh
    Commented Jul 11, 2012 at 10:09
  • \$\begingroup\$ @stevenvh 10 years on :-). No harm in most cases. I was designing a multi track tape deck drive (in 1977) and there was a brief glitch at startup for this reason. This latched a fast-rewind commend into the deck and it despooled the tape. Nothing in the code explained it :-) . Solution was both good pulldowns and a STOP!!! commend as soon as the system initialised :-) \$\endgroup\$
    – Russell McMahon
    Commented Apr 12, 2021 at 5:17

If the solenoid needs an AC drive you'll indeed need the relay, otherwise you can directly drive the solenoid with the MOSFET. They're the same kind of load.

enter image description here

Oli suggests 10 kΩ to 100 kΩ for R2, but you can even use a 1 MΩ for this. Make sure that you have a logic FET. Other FETs may need a too high gate voltage to turn on. A relay may need around 50 mA or less, a solenoid probably a couple of hundreds of mA. Select a FET with a low \$R_{DS(ON)}\$, so that even at higher currents dissipation will be low. FETs with an \$R_{DS(ON)}\$ of less than 200 mΩ are perfect and well available.

If the relay/solenoid needs 24 V or less the Si2304DS is a possibility: \$R_{DS(ON)}\$ is less than 200 mΩ, so even at 1 A it will dissipate only 200 mW. Can drive more than 1 A at 3 V gate voltage.

  • \$\begingroup\$ Why would you use a depletion-mode MOSFET (shown) instead of an enhancement mode MOSFET? \$\endgroup\$ Commented May 29, 2022 at 16:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.