2 LED on single GPIO
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 .
William Scott last edited by
@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.