1
\$\begingroup\$

When driving an NPN transistor using the GPIO output on a raspberry pi I assume no protection is needed on the GPIO side of the circuit?

So nothing would really be needed beyond this to drive the LED as seen below?

enter image description here

\$\endgroup\$
4
  • 5
    \$\begingroup\$ You need a base resistor or you will fry the transistor. \$\endgroup\$
    – winny
    Commented Oct 3, 2019 at 20:21
  • 3
    \$\begingroup\$ @winny right concern, wrong outcome. A pi won't fry a typical discrete NPN transistor. The tiny output transistor in the pi will however be stressed, and possibly damaged though it may survive this at least briefly. \$\endgroup\$ Commented Oct 3, 2019 at 20:23
  • 3
    \$\begingroup\$ @RyanMills you've just posted two questions about intefacing to your raspeberry pi while giving no information about what you are really trying to accomplish. While it's good that you didn't just say "here is my goal, please give me the circuit" you will get far better answers if you edit both of these to describe your complete goal, in addition to proposing your circuit. \$\endgroup\$ Commented Oct 3, 2019 at 20:26
  • 1
    \$\begingroup\$ Chris, Both are exactly what i am trying to do, the only thing missing is the Pi and power rails. The isolation on the other input is because its over 50 feet of wire and I have had issues in the past. In this case I dont want to stress the Pi's output and drive them from a separate power rail because their are 12 of them on separate GPIO's. Honestly did not seem polite to post the whole schematic and expect someone to sort out what section im talking about. \$\endgroup\$
    – Ryan Mills
    Commented Oct 3, 2019 at 20:46

1 Answer 1

4
\$\begingroup\$

It would be best if you provided current limiting for the GPIO port. It depends on the current gain of the NPN transistor, but at minimum a 200Ω series resistor from the GPIO to the NPN needs to be used to limit the current to less than 16mA. (and also use less than a total limit of 50mA on all ports)

\$\endgroup\$
6
  • \$\begingroup\$ I'm seeing my mistake now. The NPN I was looking to use is the MMBT3904-TP with the hFE around 200 for the load. LED load should be 10ma to 20ma Using the calculator on petervis.com it looks that I should be using a base resistor in the 2k to 3k ohms range? \$\endgroup\$
    – Ryan Mills
    Commented Oct 3, 2019 at 21:08
  • 1
    \$\begingroup\$ @RyanMills, a 10K resistor should do just fine. Don't forget to add a 47K pull-down at the GPIO pin if you don't want the LED flashing on during reset, as the GPIO defaults to a high impedance input. \$\endgroup\$
    – TonyM
    Commented Oct 3, 2019 at 21:24
  • 2
    \$\begingroup\$ 3K is a good value for the base resistor at ~15mA, but make sure you really want that much LED current. Most modern indicator LEDs are almost too bright at 5mA. \$\endgroup\$ Commented Oct 3, 2019 at 21:48
  • 1
    \$\begingroup\$ @RyanMills, say 50 mA Ic capability for a good 'on'. With your hFE of 200, that needs Ib of 250 uA. So 3.0-0.7/0.00025 is 9K2. Call it 10K because you don't want more than 2..3 mA in your dazzler LED anyway, whereby you could safely use Rb of 47K. At that point, hang the 2..3 mA LED straight off the GPIO anyway. But don't pointlessly burn current in 3K base resistors, as if hFE was 10 or something. Beyond that, look at your datasheet and you'll see the GPIO state after reset. \$\endgroup\$
    – TonyM
    Commented Oct 3, 2019 at 22:15
  • 1
    \$\begingroup\$ @SpehroPefhany I've found the same thing, a little bit of LED light goes a long way, you don't need to see the LED in the product from 1 km away, yet many LED's in products are that bright. \$\endgroup\$
    – Voltage Spike
    Commented Oct 7, 2019 at 20:45

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.