I'm driving a solenoid from a raspberry pi zero W. The solenoid doesn't work reliable, sometimes it doesn't move at all. When I position the solonoid so that it points downwards (so that gravity helps), it always works. When I drive the solenoid straight from the power supply it actuates reliably.

I'm using this schematic with some slightly different parts:

How to drive solenoids with the arduino

My parts:

It seems like the voltage across the solenoid is too low, but I measured it, and it's around 5V as it should be. Edit: I measured this without the solenoid, this is wrong. With the solenoid I'm measuring around 2V. This seems to be the problem.

Where am I going wrong?


So, thanks very much to all the answers, I realized that the voltage across the solenoid was simply too low (2.5V), due to the characteristics of the TIP122 resistor I was using. So I switched the TIP122 for a IRLB8721PbF mosfet, and It's working slightly better: around 3.15V across solenoid.

I would prefer to have the full 5V across the solenoid, but this seems hard to achieve given the 3.3V GPIO output on the raspberry, which will not turn a lot of transitors/mosfets fully on. I tried driving the mosfet using the transistor, but this gave an even lower voltage. If I read the datasheet correctly the IRLZ44N would give a better result, but that wasn't available here. See for more information: Using MOSFETS with 3.3 Volt.

Anyway, 3.15V seems enough to drive my small solenoid reliably, so that's good enough for me. Again, thanks very much for the answers!

  • 1
    \$\begingroup\$ "It seems like the voltage across the solenoid is too low, but I measured it, and it's around 5V as it should be." ... Where exactly did you put your meter leads when you measured 5V? This doesn't jive with the circuit analysis (see answers). \$\endgroup\$ – Tut May 10 '17 at 18:59
  • \$\begingroup\$ @Tut - I think you are right, I measured without the solenoid present. When the solenoid is in the circuit, I'm measuring around 2V. \$\endgroup\$ – Simon Epskamp May 10 '17 at 19:01

If you look carefully at the data sheet for your solenoid, you'll see that it draws 1.1 amps at 5 volts. Now look at the data sheet for the TIP102. Note that you have linked to a TIP122, but that's OK, the two are close enough. At 3 amps and 6 mA of base current, the saturation voltage is about 2 volts. Furthermore, for a base current of 80 mA, the base emitter voltage is given as 2.8 volts. At lower base current, figure a base-emitter voltage of about 2.5 volts. Then, for a 4 volt Arduino output and a 1k base resistor, you'll only get about 1.5 mA, which may or may not be enough to turn on the transistor completely. Even if it does, a 2 volt saturation voltage means that only 3 volts appears on your 5 volt solenoid, so it will not provide as much force as you think.

So your base drive is pretty marginal in terms of turning on your transistor, and even if you do turn it on fully, you won't get full force from the solenoid.

You should switch to a logic-level n-type MOSFET. A good choice might be an IRLZ44N.

  • 1
    \$\begingroup\$ IRLZ44 www.vishay.com/docs/91328/91328.pdf \$\endgroup\$ – Bruce Abbott May 10 '17 at 18:46
  • \$\begingroup\$ I'm actually using the TIP122, but your analysis seems correct, thank you. I'll try to buy the IRLZ44N and see if that works better. Can I use it without any further adjustments? \$\endgroup\$ – Simon Epskamp May 10 '17 at 19:03
  • \$\begingroup\$ @SimonEpskamp - You bet. It's essentially drop-in. Although you might consider dropping your base resistor to 100 ohms or so, just to cut down on the switching time, and therefor power dissipation. However, since you're apparently turning the solenoid on and off at a very slow rate, this probably won't make a difference. \$\endgroup\$ – WhatRoughBeast May 10 '17 at 20:24

BJT switches work inefficiently compared to MOSFETs....


... when used with magnetic loads of high current at low supply voltage due to Vce drop and solenoid force is reduced by current and thus voltage drop. Note the android notes do not indicate anywhere to use this TIP122 at 5V. It says 6V to allow for 1V drop or so or about 20% of your solenoid force at V+=5V. Poor design choice on your part and bad info in Android notes.

Either use a 6V supply for solenoid or use an Nch FET with RdsOn<= 200mOhm with 5V and decouple supply close to solenoid and gnd.

end edit

Other info

For this Darlington use 100 to 400 the square of above for rule of thumb. Thus if 5V into 1K is 3.6mA thus only drives 1.4A reliably. worst case. with Vce drop 0.7 to 1V. (excessive here)


To make a good switch , Rce must be < 10% Pref <2%, of DC resistance of solenoid. and since there is voltage gain from Arduino Voc to V+ on solenoid, Ic/Ib is too high for this to saturate switch and it will get hot from VI = Pd drop.

you can specify solenoid DCR in Ohms and try 10x this value for Rb and do not exceed max Pd in Arduino driver ~50 Ohm at 5V.

Or specify actual DCR and V+ for further analysis or use a low RdsOn logic level MOSFET Nch with clamp diode of same current rating if not included in MOSFET.

Use twist pairs only and avoid current loops in supply so use twisted pair there too as supply transient currents radiate EMI pulses.

Also put diode acros Switch, not solenoid unless builtin so shutoff current snub follows same direction along wires to solenoid from switch for less EMI.


Pretty bad specs on that solenoid, and the schematic does not look great either.

TIP112 will only VceSat to about 1V.. that only leaves 4V over the solenoid... I suggest you use a MOSFET instead.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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