I am trying to use a transistor to switch a 12v relay ?

I am using a micro controller to switch a transistor which will then switch on a relay. I have heard that you need a resistor in between the output pin and the base of the transistor. Why is this and how do you calculate what size. Also the micro controller is running off a 12 battery which is regulated down to 5 volts for the controller. Can a transistor use a 5 volt source to active the base and then have 12 volts running through it activating the coil on the relay. I apologise for my poor electronics knowledge.

sort by: active | newest | oldest
rickharris3 years ago

The resistor is there to protect the output pin from the possibility of voltages feeding back to the micro processor. Usually around 1K.

Depending on the transistor you should be able to do that. Check the data sheet to make sure it will pass enough current for your purposes. The transistor will have a MAX collector/emitter voltage as well.

As a general statement where you are using the transistor as a switch you need to ensure that it is turned fully on, otherwise some, possibly much of the current will be converted to heat in the transistor.

Remember you need a diode across the relay coil otherwise when you turn the relay off voltages generated in the relay coil may kill the transistor. See the manual below

Consider using an FET rather than a transistor - see the manual below.

Although this may not be the microprocessor you are uding the general principles rematin the same


legend4930 (author)  rickharris3 years ago
Thank you very much for your response. So the max collector emitter voltage is the max voltage you can switch through.

Broadly speaking yes. There will also be a max collector emitter current.

The gain, hfe, is the amplification of the device - so collector current will be base current x hfe. up to the max of both.

Transistors are current operated devices - FETs are voltage operated.

Also to limit the base current and protect the output pin Rick,