I wish to control a 12V dc motor through the GPIO pins of a Raspberry Pi. I am currently referring to this tutorial.

I have a 2N222 NPN-transistor which will used as a Switch, a 12V-2A power supply, a resistor of 1K ohms and a diode.

This is the circuit I am using:Common-Emitter NPN Transistor stage

  1. motor in the collector of the transistor
  2. Jumper from 3.3V GPIO pin through 1K to transistor base
  3. Emitter to ground
  4. Battery negative to ground
  5. Battery +12v through motor to collector
  6. ground GPIO pin to ground.
  7. a reverse biased diode in parallel

I fail to get a working circuit - every time the transistor ends up frying. Please, how I can fix this?

  • Is your transistor rated for 2 Amps+ Dec 30, 2016 at 14:16
  • electroncomponents.com/… bought it from here. I am a newbie and don't know much about electronics. Dec 30, 2016 at 14:22
  • 1
    What's the current rating of the motor? This transistor can not handle the amperage the power supply could provide.
    – Ghanima
    Dec 30, 2016 at 14:43

2 Answers 2


The 2N2222 is rated for a continous collector current of 600 mA only (that could be issue 1). To drive this current however a higher base current is required than is possible in this setup with the 1k base resistor - and the limitation of the Pi's GPIO pins (issue 2). For switching applications the goal is to drive the transistor into the saturation region (keyword to look out for when reading data sheets). For a collector current of 500 mA a base current of at least 30 mA or even more is required. If the base current is limited - in this case driven by 3.3 V and the 1k base resistor to less than 3.3 mA - saturation is not achieved and the collector-emitter dropout voltage increases. That in turn means that thermal dissipation in the transistor increases and might exceed its design limits.


Select a transistor with appropriate ratings (e.g. collector current, Ic) and sufficient driving. Darlington type transistors or FETs come to mind.

  • According to Wikipedia the 2N2222 is typically rated at 800mA with an hFE of at least 100 so to drive it into saturation (so that you get the minimum volt drop across the Collector-Emitter junction of VCE(sat) of around 0.5Volts) you may only need a maximum of up to 800mA/100 i.e. 8mA base current IMHO. The OP may well still have problems as you say though depending on the type of motor and it's current requirements - and without some more information we cannot be certain that the transistor is up to the task - and the blown ones suggest it isn't! 8-)
    – SlySven
    Dec 30, 2016 at 14:51
  • @sly then I must have read a different datasheet ;) I'll check again.
    – Ghanima
    Dec 30, 2016 at 14:55

If you only need on-off control of the motor you may wish to replace the motor in the above circuit with the coil of a 12V relay and use THAT to switch the supply to the motor. That is much more likely to be within the capability of the transistor! You will want to leave the reverse diode in the circuit of the relay's coil as it too will generate a reverse voltage when power is removed (though you will no longer have it to protect the transistor if someone should grab the shaft of the motor and give it a spin "manually" to see what happens - which is of course something that a project designer sometimes forgets to cover their project against!)

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.