1
\$\begingroup\$

I would like to connect and power a LED directly by using a GPIO pin of the ESP32 board (I am using the ESP32 NodeMCU WiFi Dev Kit C). As far as I know the GPIO pins provide 3.3V. I found some LEDs with 5V blocking voltage and 2.8V max. supply voltage. If I understand it right, it needs a resistor.

If the max. forward current are 20mA. So the resistors needs to be (3.3V - 2.8V) / 0.02mA = 25 ohm, is that right?

Is there a way to use a built-in resistor so that I do not need to add a resistor? Or how can I connect a resistor so that I can also connect the LED directly to the GPIO pin? What is the recommended way? I only worked with breadboards.

Thanks in advance.

\$\endgroup\$
4
  • \$\begingroup\$ Where is it said ESP32 maximum current is 20mA? The datasheet I am looking for ESP32 says 12mA. And that is the absolute maximum, so it is not intended to be anywhere near 12mA during normal operation. \$\endgroup\$
    – Justme
    Mar 2, 2021 at 7:51
  • \$\begingroup\$ It is the maximum current of the LED. \$\endgroup\$ Mar 2, 2021 at 15:12
  • \$\begingroup\$ @justme I have heard the 12mA figured stated in other posts and have been scouring the data sheet looking for this information. The best I can find is a listing on page 42 of espressif.com/sites/default/files/documentation/… for "Cumulative IO output current" of 1200mA. Even after searching for "12" in this document I have been unable to locate anywhere that states the maximum current output of a GPIO is 12mA. Can you provide a pointer? \$\endgroup\$
    – Lehrian
    Jun 5, 2021 at 0:59
  • \$\begingroup\$ Well, that specific datasheet you linked to is clearly different from what I've read before. This datasheet now says the typical soure current is 40mA and typical sink current is 28mA. Besides there are 4 different drive strength levels, and the default is 10mA level. So it is possible that there are different ESP32 devices which all have their own datasheet, or the datasheet has been updated. \$\endgroup\$
    – Justme
    Jun 5, 2021 at 5:46

3 Answers 3

2
\$\begingroup\$

Since LEDs have manufacturing tolerances, and also the power supply you are using to power up the ESP32 also has some tolerance, it is possible that connecting LED directly to an IO pin will exceed the safe current value.

So the maximum forward voltage value for your LED is 2.8V, but that is the best case which causes least current to flow. The worst case is the minimum forward voltage, which causes the maximum current to flow.

This basically means yes, you must always use a resistor with a LED when driving it from an IO pin. This way, you never have to worry about breaking anything.

\$\endgroup\$
1
\$\begingroup\$

For a 3.3V logic device the CMOS drivers are 25 ohms +/-25%. A 65mW White LED has an internal ESR of around 15 Ohms above 2.85V threshold approx. Thus direct drive is possible but for an indicator with today's efficacy will be incredibly bright. Even 5mA is adequate, unless you want max brightness. Although not very precise on tolerances this will work ok.

I might suggest a green LED for direct drive and choose the type of LED you like. These have a slightly higher Vf of 3.2 to 3.3 typ

\$\endgroup\$
1
\$\begingroup\$

There are, in fact, LEDs that have the resistor for a particular operating voltage already built-in, so you don't need an external one. For instance, here's a spec sheet for LEDS that can be directly attached to a 5V pin. I have a few of these directly connected to my Arduino Nano (5V operating voltage) - no problems so far, and they're on almost 7/24.

\$\endgroup\$

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.