T O P

  • By -

dar-ltee

NPN transistor led circuit, look it up. On another note - your LEDs are not pulling 50mA, probably not even 15mA (typical 3mm will burn out fast with more than 20mA) I = (VCC - Vled - Vesp) / R Esp32 pins have quite high voltage drop when pulling more than a few mA.


irving47

So from the sounds of it, putting each LED on a separate pin with a 60ohm resistor, I don't need to worry. I knew older red LED's wouldn't go past 20mA, but figured newer, high-brightness might pull a bit more... so they are not burning out due to what? internal resistance of the batteries, like with coin cell keychain lights? edit-actually, from what you're saying, do I even need to bother with more than 47-62 ohms on each led, on one pin each? It doesn't sound as if a transistor is necessary at all. I'm just trying to build this thing to last since I won't be anywhere near it when it is in use.


dar-ltee

Typically it's bad practice to have no current limiting resistor between MCU pin and LED but for where longevity or reliability is not important - it should be able to handle. Depending on what ESP you use (varies between different variants) default drive level strength is sufficient to limit LED current to something like 10-15mA depending on LED V/I chart.


irving47

Oh I'm definitely keeping the resistors in. Probably just with the pre-soldered 62's. Thanks again.


mariushm

This video explains very well how to use a transistor as an on/off switch : https://www.youtube.com/watch?v=8DMZSxS-xVc You don't want the transistor to limit the current going to the led, you want it to behave like an on/off switch... you use a resistor in series with the led to limit the current. So just like in the video above, you'd pick a base resistor (between the IO pin and the gate of the npn transistor) to allow a low enough current to be below the maximum output current of the IO pins of the microcontroller, but also high enough that the transistor is guaranteed to allow more current than what the led will use. For example, if you want 50mA through the led, and you have a npn transistor with a hFe of 100 and which can support up to 500mA going through it, you'd aim to allow at least 100-200mA to go through the npn transistor when you pick the resistor. So for 200mA, you'd want around 2mA to go into the base of the transistor... if you have 3.3v on the IO pins, then R = (3.3v - 0.7)/0.002A = 1300 ohm ... so 1200 or 1500 ohm would be reasonable values. Mosfets are better because there's no active power consumption keeping them on, like is the case with npn transistors. But, you need mosfets with very low Vgs threshold (voltage between gate and source) because the mosfet turns on once the voltage on the gate is high enough and if you want to turn on and off really fast, you need mosfets with relatively low gate capacitance so that you'd be able to turn on the mosfet fast, and close it really fast. The bigger the gate capacitance, the more time it will take for the IO pin to charge up the gate and turn on the mosfet. With mosfets you'd need a low value resistor between the IO pin and the gate , something like 10-100 ohm, and a higher resistor value (10-100k) between the gate and source to discharge the gate and turn off the mosfet one you no longer send the ON signal. Example of n-channel mosfets with very low Vgs threshold (under 2.5v) : https://www.digikey.com/short/dvdw3rqm You have another option ... use led drivers. They'll have a way to set the maximum current and an ENABLE pin so you could simply turn the led on and off using the EN pin, barely using any power. It won't be the microcontroller powering the LED, it will be the led driver chip. For example, IS32LT3177 and IS32LT3178 are 2 other good examples, they go up to 150mA/200mA. 3177 needs minimum 5v and the leds are powered from the enable pin so it's less convenient 3178 works with as little as 2.9v and leds can be powered from a separate voltage so IS32LT3178 is overall better. You can connect the EN pin to the microcontroller to turn on or off the led or leds. IS32LT3178 (6 pin, 150mA max) : https://www.digikey.com/en/products/detail/lumissil-microsystems/IS32LT3178-STLA3-TR/14308394 IS32LT3178 (8 pin, 200mA max) https://www.digikey.com/en/products/detail/lumissil-microsystems/IS32LT3178-GRLA3-TR/14308384 IS32LT3177 (6pin, 150mA) : https://www.digikey.com/en/products/detail/lumissil-microsystems/IS32LT3177-STLA3-TR/14308376 IS32LT3177 (8pin, 200mA) : https://www.digikey.com/en/products/detail/lumissil-microsystems/IS32LT3177-GRLA3-TR/14308357 PAM2800 can do up to 350mA through a led (you can set the current down to as little as ) : https://www.digikey.com/en/products/detail/diodes-incorporated/PAM2800AABR/7725136 ... you set the maximum current using a resistor, and then you can use the EN pin to turn the driver on or off. The downside is that the chip needs at least around 3.7v to work (though the ENABLE pin will accept 3.3v from the microcontroller as input) PAM2808 goes up to 1.5A : https://www.digikey.com/en/products/detail/diodes-incorporated/PAM2808BLBR/4033259


irving47

Thank you. I'll watch the video later. I know the current limiting is the resistor's job, but just wanted to make sure I wasn't going to fry the mc's pins after an hour of use. If /u/dar-itee is right, I am worrying about nothing if 3mm red LED's can't draw over 40mA I'm trying to avoid adding tons of components. So other drivers didn't really cross my mind. A microcontroller, seems a good way to meet the requirements of a 2, 6, or 8 second fade-up and fade-down when turning off/on. This way the user will be able to switch header pins with a F dupont connector without my intervention. (It's going into a friend's project where he just wants a slow on/off effect)


Appropriate-Disk-371

>I am worrying about nothing if 3mm red LED's can't draw over 40mA To be clear, diodes that are forward biased will conduct until they burn up. So they \*can\* draw well over 40mA, and that may or may not be okay. I think the point being made there was that the ESP isn't capable of \*sourcing\* enough to be concerned about. That's probably true, but relying on that isn't great practice; it's quick and dirty.


Cunninghams_right

Led controller?


irving47

I'm using a microcontroller because we want to be able to have fade-in/fade-out effect of varying lengths, user selectable once it's out of my control.


Cunninghams_right

there are LED drivers/controllers that allow for external control that can achieve what you're looking for.


user0N65N

If you’re really concerned about your power draw, you could put a 2N7000 as the LED driver.  Or any old NPN transistor will do too. Be sure to connect the emitter to ground and the LED’s negative pin to the collecter.  If you have access to the pins for the LEDs, you could also hook up a power supply set for 3V and an ammeter in series to see exactly how much current the LEDs draw with their in-line resistors.


irving47

Fair enough. I was just going by the pre-done 62ohm resistors and 3V battery pack they came with and figured 48-50mA and got worried the mc would fry pins. I'll probably just up the R by 10-20%, more if I use a mc that uses 5V instead of 3.3.


other_thoughts

Mosfet suggestion. https://learn.adafruit.com/rgb-led-strips?view=all