I'm trying to control a solenoid using the RasPi 2's GPIO pins. Since the solenoid needs more power than the RasPi can provide, I'm using a 9V battery to provide the power.

I started with just wiring the circuit and checking if it works by connecting and disconnecting the 3v3 output to the board.

First, here's the wiring I'm currently using:


The diode accross the solenoid inputs is a standard flyback diode, and the resistor is a 1kOhm resistor.

The inductor represents my solendid, which I got from Amazon. As far as I can tell, it requires 12V / 1A to operate, but connecting the 9V battery straight to it (skipping the transistor) works nicely enough. Even the RasPi 5V output provides a weak activation.

However, when going through the transistor, the solenoid does not activate properly. I have noticed that when the base pin is on though, it will "hold" the end position if pushed manually, just not push towards there by itself. It does not do this if the base 3v3 pin is not connected.

I tried using a BC547 NPN transistor, then I figured the output current was not enough, so I switched to a BC639, but that didn't help either.

My question is, what transistor should I use? Am I doing anything else wrong? I've seen other people use a TP120, which seems to have an even higher output current.

Since I'm setting up a circuit with 24 of these, I'd like to know for sure before ordering another batch of transistors.

  • I ran into this today, though it is for Arduino, in case there are no other answers this can lead you somewhere: glacialwanderer.com/hobbyrobotics/?p=9
    – user29503
    Sep 26, 2015 at 20:39

1 Answer 1


See http://elinux.org/RPi_GPIO_Interface_Circuits for suggested interface circuits. A BC547 won't switch 1A, and with the limited current output from the Pi no transistor is likely to have sufficient gain. You need a darlington pair, but you would be better to use a FET.

Your picture shows a 9v battery. If you are really using one of these it won't work, as the battery won't provide 1A (at least not for more than a couple of seconds).

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.