2 LED on single GPIO
I'm a programmer not an electronics guy so I've been playing with the projects in the project book and I have a question, with Omega2+. Is it possible to connect 2 LED to a single GPIO? My circuit would be:
GPIO1 --> 2 x LED in parallel, each LED is then connected to a separate 200 Ohm resistor, then each resistor connected to GND.
Is this any problem?
It may be a problem because putting the LEDs in parallel means double the current compared to a single LED and the GPIO port might become overloaded.
To run them in parallel safely you need some kind of buffer/driver in between (eg a transistor/FET/Driver IC etc).
Traditionally, to run 2 LEDs at minimum current we would put them in series but then the voltage required to illuminate them will very likely exceed 3.3v and they won't light up - again a driver required.
What is the intended idea behind 2 LEDs from one port? There may be another solution...
The voltage drop across the LEDs will be less than 1 volt. Two in series should work fine. Just reduce the size of the current-limiting resistor, if necessary. As stated above, two in parallel demands more current, which could be a problem. In series, the current lighting one LED is the same current lighting the second LED. The Omega won't know the difference.
@Robert-Jensen 1v? Not quite there. Typical forward voltage of lowest - Red LED - is 1.8v so using two in series would be 3.6v which is just a tad short of the 3.3v available supply rail. Are you mixing it up with the forward drop of a typical silicon rectifier or transistor junction (0.6v)?
@Chris-H The reason I want 2 LED on a single GPIO is because the LED are in a small enclosure I am illuminating. A single LED doesn't illuminate the space sufficiently so I need a second LED in a different location. I can't use a brighter LED because they do not work aesthetically. I built a test board and it functions well, I just want to make sure the thing is not going to go up in a puff of smoke in a few weeks time.
I guess I could put a second LED on a different GPIO, but I actually have 4 pairs of LED, each pair is illuminated at different times so at any one time there are only 2 LED powered. So I would need 8 GPIO if I wanted to run each LED off a different GPIO, which seems messy.
It's tricky to find any data on the current sourcing capability of the GPIO pins. I only had a quick look in the Onion docs and the Mediatek datasheet without success.
You're drawing ~15mA from the port with the arrangement you describe assuming the 1.8V LED drop per @Neil-Manuel's reply. Once you find the maximum current source rating on the GPIO pin you can make a call.
It's also worth checking the sink current rating vs the source current as sometimes the sink current is the greater amount. In this case, you reverse the LED(s) direction, attach the resistor(s) to +Ve and switch the GPIO off to activate it.
Thanks @Chris-H maybe it is safer to use separate gpio per LED. I don't want to let the smoke out of the Omega.
@crispyoz is there a specific reason you have calculated 15mA drive for the LEDs?
A lot of first timers look at the 20mA current ratings for a LED, calculate the resistance for it, power it up and wonder why its lighting the whole room!
The reason I ask is because I have found, in practice, with currently efficient LEDs you can get an appreciable light output with a mere 5mA or even less. If you reduced the current to each LED to, say, 4mA I'm sure that an 8mA draw from each GPIO pin is then quite do-able without releasing the magic blue smoke.
If you experiment with a 3.3v supply and some resistors you can find a point at which the LED is bright enough whilst drawing minimal current.
@crispyoz You really like the Full-Color Notification LED of Omega2 Pro anyway. ;-)
Why don't you use a ledchain?
Only one GPIO (GPIO18 or GPIO19) and four WS2812B LEDs needed and you could switch On/Off any LED and you could also set the brightness and the color of any LED.
5Pcs One Bit WS2812B Serial 5050 Full Color LED Module US$ 5.39
10Pcs Geekcreit® DC 5V 3MM x 10MM WS2812B SMD LED Board US$1.87
@György-Farkas err for info the item you pointed to is a 5v device - this is a 3.3v system. Would it work on 3.3v?
The protocol is messy for driving those "clever LEDs" - might be more trouble that it is worth for the task required.
@Neil-Manuel I think only a "bare bone" Omega2 is a 3.3V powered device / "system".
I think @luz's p44-ledchain package works fairly well and it's part of any (?) Omega2 OpenWrt 18.06 based firmware.
Try it please. :-)
Hahaha @György-Farkas yes i do love the LED on the Pro it's so bright and beautiful :) but the Pro is too big for my purpose. I decided to bite the bullet and have my own board designed and stick all my LED on individual GPIO. My software is much easier for me to change.
@crispyoz I wrote only 1 (one) GPIO (GPIO18 ie. PWM0 or GPIO19 ie. PWM1) and 4 (four) WS2812B LEDs as a ledchain.
It doesn't depend on any Omega2 version.
(Vsupply - Vled)/R = (3.3 - 1.8)/200 = 7.5mA per LED x 2 = 15mA.
I agree @crispyoz could probably get away with higher value resistors (lower current per LED) and still get reasonable light levels. Alternatively, the GPIO might be able to safely handle 15mA, I just ran out of patience trying to find the spec 😜.
@Chris-H Regarding biasing LED, making a guess on voltage drop is not a bad deal as you can get to a solution fast....or slow....depending on the guess. On the other hand a more design-forward approach would certainly get you to a solution on first try. Here's what I would do.....
Find the data sheet on the LED. Among all of the tech data you will find a V-I curve (at voltage x you expect current y). Now guess (yes - guess!) at a sensible voltage to turn on the display. Better yet, if you have a variable voltage supply, apply it to the diode at near zero volts and increase until you have the brightness you desire (or until it explodes). Now with your guess from whichever path you chose, the remainder of the voltage drop must be across the resistor. With the measured or graph derived current you can select a ballpark resistance value. Find the nearest off-the-shelf resistance value you have and you'll be good to go.
@Chris-H thanks for looking into that, I realised I have one of my IoT devices (O2+) running two LED on a single GPIO for about 5 weeks now. So far no smoke. Nothing seems to be getting even warm as my software is very light on the CPU. I'm going to let it run for as long as it takes to finally release the smoke.
Not exactly scientific, hence my original question, because as a computer scientist I prefer to work with calculable facts. I appreciate your advice.
@György-Farkas yes I started experimenting with a LED strip I have which uses the WS2812B LED. Dimming these things smoothly is my current challenge.