I have a microcontroller that is not 5v tolerant and I need to drive IR leds just like in the attached circuit.

enter image description here

What I thought of doing is using the 5v line from my raspberry pi as the load voltage across the leds and grounding the ULN2003 back to my raspberry pi instead of the other 3.3v tolerant microcontroller.

But I'm wondering if:

  1. If it even matters if I ground the uln2003 to the raspberry pi or the other 3.3v microcontroller? I obviously know that you should not apply a voltage greater than 3.3v to a 3.3v tolerant microcontroller, however, doesn't the voltage drop to 0 at this point, so in theory it should be safe?

  2. like I said before, "I obviously know that you should not apply a voltage greater than 3.3v to a 3.3v tolerant microcontroller." but can you apply a larger voltage to a component thats in a circuit with that microcontroller?

To note: I cannot use the raspberry pi to drive the leds instead of the microcontroller.

  • \$\begingroup\$ how much current do the LEDs require? What's their forwaerd voltage? Feels like the ULN2003 with its excessive voltage drop isn't the greatest choice, and you've forgot the series resistors for the LEDs. \$\endgroup\$ – Marcus Müller Oct 4 '19 at 23:09
  • \$\begingroup\$ the leds require 0.1A, in reality I have 7 ohm resistors in line with each led, so the forward voltage would be 0.7V. But to repeat my questions, would it even matter? @MarcusMüller \$\endgroup\$ – Ietpt123 Oct 4 '19 at 23:12
  • \$\begingroup\$ it matters. You need a shared ground, otherwise the chip wouldn't define what "on" or "off" would be as you want... But to answer your second question: sure with an appropriate driver, you can switch higher voltages than 3.3V. I'm pretty certain that the ULN2003 isn't really the solution for you, though, to be honest: a simple NPN transistor (plus base resistor) per channel would do better. Sure, you'd save yourself a bit of soldering with the ULN2003, but you'd drop twice the voltage when turned on, and need to cool that away. \$\endgroup\$ – Marcus Müller Oct 4 '19 at 23:17
  • \$\begingroup\$ do not use a microcontroller to drive LEDs ... use the microcontroller to control the LED state ... the drive current should come from a power supply \$\endgroup\$ – jsotola Oct 5 '19 at 2:20

You can drive the ULN2003a with 3.3V outputs- they don’t put any voltage onto the driving circuit.

Of course if you mess up the circuit or the grounding your chances of ruining the Pi are much higher than if you use 3.3V only.

You need series resistors for the LEDs and you should make sure that the maximum total current can be supplied by the 5V supply. Since they don’t tend to be grossly overrated it’s unlikely an extra 800mA will be acceptable. Also, in your comment you mention 7 ohms, which would yield several hundred mA and quickly destroy the LEDs and the ULN2003.

If you use an auxiliary supply the ground must be common. Connect the supply ground to the ULN2003 ground directly and that junction to the Pi ground.

If you’re making a PCB there are nifty SOT-23 MOSFETs that have very low voltage drop at 100mA and can be driven directly from the Pi.

  • \$\begingroup\$ The attached picture is not my actual circuit I was just trying to use it as reference. The current across the leds in my actual circuit is 0.1A, with 7ohm resistors at each output of the uln and before the led, the 5v load on the opposite side of led comes my RPi. How does or does this change your answer? \$\endgroup\$ – Ietpt123 Oct 4 '19 at 23:32

The ground connection MUST be common to all device involved*.
Without a continuous circuit there can be no current flow.

The ULN200X is effectively just a group of Darlington open collector transistors in a package. You can "safely enough" drive each section with a correct voltage input (varies with the X in 200X) and then drive outputs that the Darlington suits. The 200X has a well specified output voltage drop at a given current. If that suits your load then it suits your load.

The 200X devices are reasonably rugged and will generally not destroy driving devices when used within specification. Damage would only occur if you destroyed all or part of the 200X by unsuitable conditions. If you are worried about damage to the microcontroller you could use an isolated driver (such as an optocoupler) or high impedance drive to a MOSFET with clamp diodes. This will not usually be required.

As you have not provided us with an LED part number, or LED Vf or other specs we cannot tell if the darlington driver does suit the load.


[*Except if you have an isolation device such as an optocoupler, which effectively has isolated input and output grounds.]


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.