transistor as switch: what value of resistor to use at the base?

am trying to create an automatic plant watering system as outlined here

its a very simple project. uses the arduino to activate the motor via a transistor, which acts as the on/off switch for the motor with a dedicated power supply. so the arduino output pin at the base activates the transistor. the author of the article says that since PN2222A is the transistor, no resistor is needed in between the arduino output and the base. but if some other transistor were to be used, what should be the value of the resistor to be used?(am intending to use the 2N2222 instead of PN2222A)

in general, how to compute this?

I'm still new to Arduino so someone else could probably chime in and correct me if i'm wrong.

You wouldn't use a resistor between the output pin because the amount of current needed to open the transistor is lower than the Arduino is capable of putting out. For example, I looked up the specs for the UNO not to long ago and I think it was 40mA per output. That means your transistors are using less than 40mA to activate them.

So look up the required current for the transistor your considering as well as the limits for the Arduino that your using and it will let you know if your going to have a problem.

As for using a resistor on the base, I don't think this would be helpful unless the the transistor had a pretty low resistance. You could find the base pins resistance and uses ohms law to calculate the current draw, see if your arduino can keep up.

cloud9: am trying to create an automatic plant watering system as outlined here

its a very simple project. uses the arduino to activate the motor via a transistor, which acts as the on/off switch for the motor with a dedicated power supply. so the arduino output pin at the base activates the transistor. the author of the article says that since PN2222A is the transistor, no resistor is needed in between the arduino output and the base.

Complete nonsense. Alas many instructables contain bad errors and this is no exception. No transistor can tolerate 5V from base to emitter, it will burn out. What the author of the instructable has discovered is that the 40 ohms or so output impedance of an Arduino pin is enough to prevent the 2222 from melting. Alas it will damage the Arduino pin.

but if some other transistor were to be used, what should be the value of the resistor to be used?(am intending to use the 2N2222 instead of PN2222A)

in general, how to compute this?

Whatever transistor you need a minimum resistor value of about 150 ohms to limit the Arduino pin current to a safe (non damaging value). This is about 30mA, the maximum I'd use given the abs max is 40mA.

With 30mA through the base the 2222 can switch about 0.3A maximum without too much voltage drop. There are plenty of better transistors these days. You have to read the datasheet to see what the device saturation characteristics are. Don't be fooled into thinking that the DC-gain parameter applies to saturation, it does not.

Base current, with this transistor, should be 1/10 of the motor current.
1/5 is wasting resouces, 1/20 is getting into the dangerous area (not fully saturated, getting hot).

With a 150ohm base resistor, as MarkT suggested, you get.
(5volt Arduino - 0.7volt BE junction) / (150ohm + 40ohm internal) = 4.3/190 = 22.6mA base current.
Leo…

jcarver1112: I'm still new to Arduino so someone else could probably chime in and correct me if i'm wrong.

You wouldn't use a resistor between the output pin because the amount of current needed to open the transistor is lower than the Arduino is capable of putting out.

Consider yourself corrected.

The 40mA is not the limit that the Arduino CAN put out it is the limit that it SHOULD put out.

MarkT: Whatever transistor you need a minimum resistor value of about 150 ohms to limit the Arduino pin current to a safe (non damaging value). This is about 30mA, the maximum I'd use given the abs max is 40mA.

With 30mA through the base the 2222 can switch about 0.3A maximum without too much voltage drop. There are plenty of better transistors these days. You have to read the datasheet to see what the device saturation characteristics are. Don't be fooled into thinking that the DC-gain parameter applies to saturation, it does not.

thanks a lot MarkT

Hi, I had a look at the in(de)structible that said you do not need a base resistor.

The OP claims that the base can with stand more than 5V.

What he has read is the Veb parameter which is the REVERSE bias max voltage of the 2N2222 which is quoted as 6V. The base of the 2N2222 NPN is of course forward biased, so behaves as a diode junction and a voltage drop of 0.6V or 0.7V

Tom..... :)

AddOhms Youtube on using BJT's as switches.

AddOhms Youtube on using FETs.

Even logic level FETs use a resistor in his examples.

You're better off driving a motor through FET's than BJT's.

GoForSmoke: Even logic level FETs use a resistor in his examples.

I see his circuit diagram shows connecting 3.3V to the base of a bipolar transistor with no series resistor "which allows one milliamp of current to flow". Very wrong!

I like this article for its explanation of the math for calculating values and using a transistor: http://www.ermicro.com/blog/?p=423

jcarver1112: I'm still new to Arduino so someone else could probably chime in and correct me if i'm wrong.

You wouldn't use a resistor between the output pin because the amount of current needed to open the transistor is lower than the Arduino is capable of putting out. For example, I looked up the specs for the UNO not to long ago and I think it was 40mA per output. That means your transistors are using less than 40mA to activate them.

So look up the required current for the transistor your considering as well as the limits for the Arduino that your using and it will let you know if your going to have a problem.

As for using a resistor on the base, I don't think this would be helpful unless the the transistor had a pretty low resistance. You could find the base pins resistance and uses ohms law to calculate the current draw, see if your Arduino can keep up.

OK, a little advice.

Everything you have said there is wrong.

Please refrain from offering advice here until you learn how transistors and ICs function. OK?

More reading - a lot more reading - less writing.

Paul__B: Everything you have said there is wrong.

Well, not quite everything. He did say he was new to Arduino and that someone could correct him :)

Russell.

I'd go with a logic level, low Rds N-channel MOSFET, AOI-514, to connect motor '-' to Gnd. http://www.digikey.com/product-search/en?vendor=0&keywords=aoi514&stock=1 Pretty close to being a zero ohm switch.

i found a "base resistor calculator" here: http://electronics.stackexchange.com/questions/180272/while-using-arduino-to-close-a-circuit-the-output-to-transistors-base-is-it

cloud9: i found a "base resistor calculator" here: http://electronics.stackexchange.com/questions/180272/while-using-arduino-to-close-a-circuit-the-output-to-transistors-base-is-it

That calculator is rubbish. Use the base current = (collector current)/10 rule for switching as previously advised.

Russell.

Always check out the datasheet though, then you'll know the sort of heat dissipation involved too.

russellz: That calculator is rubbish. Use the base current = (collector current)/10 rule for switching as previously advised.

Russell.

yeah, after digging around a little bit for more info, am also having doubts about that calculator

As soon as you see "Maximum base voltage 6V" you should be suspicious. Base voltage is determined by base current and is usually about 0.7 V. 6 V would kill it. He is confused with the maximum reverse base voltage which is entirely irrelevant here.

Russell.