I need to activate a solenoid using a raspberry Pi, to do that I'm using a TIP121 to drive the current and a 12V power supply to power the solenoid. I also put a clamping diode (1N4001) but I'm not sure if it's the right one.

Here is the schematic, I couldn't change diode's value on the schematic, so ignore this value.


simulate this circuit – Schematic created using CircuitLab

Is the 1N4001 enough or I need another one? It it's not the right one, how do I choose/calculate the right diode (I googled but I didn't find anything useful).

  • 1
    \$\begingroup\$ The coil will store a certain amount of energy, and discharge it over a certain time. Just make sure that the resultant current isn't too much for the diode. \$\endgroup\$ Sep 9, 2013 at 23:02

1 Answer 1


A guideline is that the diode must be able to handle the current drawn by the solenoid. If your solenoid draws less than 1A an 1N400x will do fine.

Note that you use a darlington (often a good idea because the RaPi can supply only a small current and a darlington has a high current gain) but the maximum base-emitter on voltage of a TIP121 can be 2.5V, which leaves only ~ 0.5V for R1 (assuming a high output of 3V from the RaPi, not unreasonable as a first guess). A value of 4.7K will result in 0.1mA base current. With the minimum gain of 1000 this will support only 100mA collector current. If you solenoid draws less, fine. If it draws more you must lower R1 accordingly, but you will have to check what current the RaPi can supply, and how much its output voltage will drop at that current.

  • \$\begingroup\$ a 1n4001 is more than enough for this application. I'd even chance a 1n916 since it is nonrepetitive load It can handle at least 1 ampere as long as your switching period is long enough. \$\endgroup\$
    – HL-SDK
    Sep 10, 2013 at 1:39
  • \$\begingroup\$ My power supply has a maximum output of 1A, so it's going to be fine. I'll double check the value of this resistor and also do some tests. Thanks! \$\endgroup\$ Sep 10, 2013 at 9:13
  • \$\begingroup\$ A possible improvement is to use a zener diode with a close-ish breakdown voltage to kill spikes in either polarity, some kit I work on uses a ~20v zener in almost exactly this application. Also, not sure if it makes a great difference but I'd connect the anode to ground rather than the top of the transistor. \$\endgroup\$
    – John U
    Sep 10, 2013 at 12:36
  • 1
    \$\begingroup\$ @JohnU Connecting the diode anode through ground means the reverse EMF current has to flow through the transistor, or back through the supply possibly damaging either/both. The current setup only has reverse EMF current flowing through the protection diode and the motor. \$\endgroup\$ Sep 10, 2013 at 16:55

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