6

I've recently started doing basic diode connections (red and green diodes). I've also got blue diodes, but there's one thing that prevented me from connecting them already, namely - the specs say they're 3.3V.

While calculating resistor value, I'm doing simple: 3.3V - ULed / 2mA to obtain resistor value needed to draw default 2mA.

But if the forward voltage of blue diode is said to be same as supply voltage of my GPIO pins, how would then things work? Will the rpi be just 'unable' to power up the led? And if it will (and diode will do just fine with lower voltage), how should I calculate resistor value?

1
  • NOTE:* A confusing topic perhaps... a more recent question has been marked as a duplicate to this question. However, as I read these questions, it seems to me that the answers omit a key fact: There are 3.3v LEDs available, and they do not need an external resistor to operate. This question has also been asked and answered in the SE EE forum. @ikku
    – Seamus
    Aug 19, 2018 at 17:48

4 Answers 4

6

The 3.3v forward voltage drop that you talk about, is specified at a certain forward current. This is just a point on a Forward Voltage Drop / Forward Current curve. In the datasheet of the LED you should also have the total curve. You can use this curve to select a different point for a different drop voltage / current, this implies you will not be using the LED at it's brightest. A good example of how to do this can be found here.

1
  • Many thanks! surprisingly, I was looking for something like 'electronics' stackexchange (as I predicted it might be a better place to look for an answer), but only on the footer here, so I just didn't find it.
    – Bartosz
    Dec 17, 2012 at 12:00
4

You can connect the anode of the LED to the +5v and pull the cathode to GND with the GPIO pin. This gives you 850 ohm for 2mA. 820 ohm should work fine too.

    +5V
     |
     >
     > 820 ohm
     >
     |
     |
     V LED
     -
     |
     |
    GPIO

17
  • Yeah, that would work if I didn't want to control them (I didn't state it in my question).
    – Bartosz
    Dec 17, 2012 at 12:18
  • 2
    @Bartosz, You can control it. When the GPIO is low, the LED will be on. When the GPIO is high (3.3V) the LED will only have 1.7V across it, so won't light up. Dec 17, 2012 at 12:24
  • Oh damn, care to elaborate 'pull the cathode to GND with the GPIO pin'? The diagram could be also nice:)
    – Bartosz
    Dec 17, 2012 at 12:27
  • Thanks, needed to refresh my knowledge about potential difference a bit, I think I was missing quite big chunk of the overall picture:)
    – Bartosz
    Dec 17, 2012 at 14:00
  • 1
    I'd be wary of connecting a voltage over +v of the chip to a gpio, although the led threshold should not allow any current into logic high at +5V. Investing in a few transistors would be cleaner, like in blog.jacobean.net/?p=158
    – XTL
    Dec 19, 2012 at 7:53
1

The OP asked 3 questions:

  1. But if the forward voltage of blue diode is said to be same as supply voltage of my GPIO pins, how would then things work?

What this means is that the manufacturer has integrated a resistor with the LED. This relieves you of having to size the resistor yourself, and insert another component in your circuit. The manufacturer has chosen the proper resistor value for connecting the LED across a 3.3v supply (RPi GPIO pin for example).

  1. Will the rpi be just 'unable' to power up the led? And if it will (and diode will do just fine with lower voltage),

The RPi will be able to power up the LED from any 3.3v output. If you reduce the voltage below 3.3v, the LED will still light up when this lower voltage is applied to a point. At some point, if the voltage is low enough, the LED will no longer illuminate because the forward current is too low, or your supply has not forward-biased the LED.

  1. how should I calculate resistor value?

Again, as long as the LED has an integrated resistor (which will be the case when the LED is specified as a "3.3v LED"), then you need not calculate, or add, another resistor to your circuit.

Finally, you should always consult the spec sheet published by the manufacturer for the device as the "ultimate authority" in these matters. Spec sheets are available online from a variety of sources. Mouser's website is one I use; they list a large number of 3.3v LEDs in their catalog.

3
  • TWIMC: Care to elaborate on the downvote? If I've missed something, I'd like to learn of it.
    – Seamus
    Aug 19, 2018 at 17:52
  • I'm confused about why this is the only thing I've ever seen that suggests 3.3v forward voltage on an LED just means the LED has an integrated resistor. I'm pretty sure that's not correct. As far as I knew, blue LEDs, and therefore also white ones, have an actual forward voltage on the diode of 3.3v Dec 27, 2020 at 12:58
  • @thomasrutter: What do you think it means? The forward voltage drop of an LED isn't a single value - it varies IAW forward current, temp & other variables. Ordinarily, when one offers an LED with a specific voltage - this is what it means - for example. And FWIW - I'm pretty sure it is correct.
    – Seamus
    Dec 27, 2020 at 22:35
1

Yikes! It is a fallacy to assume that all LEDs "rated" at 3.3V in the parts search matrix have an integrated resistor! The example linked above is a for a family of LEDs intended to be driven from 12V, most likely for automotive applications and would not pertain to the typical device interfaced with a platform like the R-Pi. Any lower voltage to that specific family would result in significantly dimmer operation and the Blue version would likely not light up at all with a 3.3V supply or GPIO.

Now, here's the thing. Diodes are made from different semiconductor materials.The light wavelength(color) given off is related to something called the "Band Gap" which more or less dictates the voltage required to create enough energy to expel electrons from their quiescent state. Perhaps more accurately, it's the voltage required to "switch" the diode on, the current flow then exciting the electrons out of their shells/states(the so-called "shell" is not so much a dimensional construct). It is in fact, the return of these electrons to their normal state that causes the excess energy to be shed in the form of a photon(or light "particle/wave/thingy"). The band gap is a function of the semiconductor material used as well as doping materials and concentrations.

Up until the late nineties/early aughts, the only mass producible LED colors were from the InfraRed range of the spectrum though a Yellow-Green color and even those colors were less "pure" than we can do with todays fabrication tolerances. The Blue LED was invented many years prior to it's commercialization, but was simply too expensive to produce and even the first ones to market(The Silicon Carbide formula IIRC) cost something like $3 per LED at a time when Red or Green ones were maybe in the $0.15 range or so.

OK back to diode properties, as it stands, the shorter wavelength LEDs are simply made with semiconductor materials which end up having a higher band-gap voltage in order to generate visible light of those colors. Of course, the end user doesn't need to set the forward voltage of the diode. It's properties will cause the voltage to "switch on" to it's intrinsic Vfwd as long as the initial applied voltage is higher than that threshold, but if the supply voltage is significantly higher, then an unregulated amount of current will flow(in the ideal textbook case it would be infinite, but of course the real world has non-zero resistance in the supply/battery, wires or traces, and even the diode itself has some ESR(Equivalent Series Resistance). Also the supply or GPIO has some limit of deliverable currrent.)

So, the initial "rough-in" design is to assume a drop across the diode of it's rated Vfwd, subtract that from the supply voltage, and apply Ohms Law to determine the resistor value needed to cause the desired current flow through the diode.

Now back to the 3.3V LED from a 3.3V supply/GPIO issue. In the real world, few components have truly "static" parameters(even a resistor changes with temperature). The Vfwd specified in the tabular portion of the datasheet is usually either the nominal or maximum value and is also sometimes specified at the rated max continuous current. For example 20mA is a common current rating for discrete LED indicators(as opposed to ones used/intended for significant illumination/lighting). So a Blue LED may be rated as 3.3V/20mA, but that doesn't mean that it gives off no light below either 3.3V or 20mA. That rating is usually somewhere near the LED's peak brightness rating that can be safely sustained without damaging the component. Look further into the datasheet and you'll find, well...., more data! The data you want to find is the relationship between Vfwd vs current as well as brightness vs current.

Since today's LEDs are much brighter than the ones of yore, unless you're intending to use the LED for significant illumination(in which case you're certainly NOT going to be driving it from a GPIO!), you'll be happy, or even less blinded, by the intensity given off at a small fraction of the max rated current. Most uses target such LEDs are in the 2mA-5mA range, especially if the 20mA brightness rating is in the 100mcd order of magnitude. What you'll likely find is that that 3.3V Blue LED has a VFwd more like 2.8-3.0V in that 2-5mA driving current range and will illuminate just fine. In fact many vendors will "screen" parts from their 20mA families to separate parts/batches that are significantly brighter at these lower(10/5/2/1)mA currents and sell them at those ratings(the pricing is somewhat higher as the screening incurs an additional process step). However, you'll probably find that "under-driving" a 20mA LED will provide more than enough brightness.

What is usually done, for any device/product that has multiple voltage rails, is to arrange the LEDs in a "current-sink" configuration so the node being switched is at the LED Cathode and not the Anode and to use a marginally higher(usually 5V or even a dedicated 4V "Vled" supply to reduce linear power waste) to drive all of the LED anodes in the system. You'll notice that most dedicated LED Driver matrix chips and LED Shift Registers all utilize sinking outputs and use a single current setting resistor(and internal current mirrors) to control the drive strength of 8, 16, or even up to 48 or more LEDs! Driver chips made for RGB LEDs may have three current set resistors or internal register settings to accommodate the different forward voltage thresholds of Blue, Green, and Red elements. One thing to note is that newer "true" green LEDs as well as the green element of an RGB array are more like Blue LEDs in their semiconductor makeup and are usually just a couple tenths of a volt lower VFwd than their Blue counterparts(2.7-3.0V vs 3.0-3.3V). It makes sense that you need more energy(voltage) to generate higher frequency(blue-er color) light.

Finally, despite all of the above complexities(special driver chips or registers and dedicated LED supplies), for a handful of simple indicators driven directly from 3.3V MCU GPIOs with no access to a 5V rail, just choose components that are bright enough(say 30-ish mcd - I won't get into color perception here!) at 2-5mA and use them to "sink" the cathode current directly. Of course this has the software implication that a logic zero bit is the "ON" state. But that's just a matter of "typing"! This can also be a good thing as many MCUs reset their GPIO to a weak pull-up state and that can cause all the LEDs to be lit dimly while in reset or until firmware initializes the GPIOs used for them.

Be mindful of the GPIO's max continuous current capability(often times, rated sink current will actually be higher than sourcing current - another reason to sink instead of source directly connected LEDs). Also, sometimes an MCU will have a handful of dedicated pins or a special GPIO "port" that is rated for higher current draw(in the 20-25mA range) along with the remaining GPIOs which are usually rated for at least 4mA in case you need a couple of bright LEDs to be directly driven(or for relays or even just to achieve higher slew rates on capacitive loads). Alternatively, just add a BJT or FET switch(N Type for sinking) to allow for higher current draw(the new limiting factor being the transistor's rated current, which is often much higher). This also has the benefit of restoring the conventional "1 is ON; 0 is OFF" software "polarity".

Sorry for the long post on a years old question, but I'm hoping this will have educational value to any newcomers who stumble across this topic!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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