Source from 5V, sink to 3.3V pin?

I have what is probably a very fundamental question about voltage.

I am using ESP8266 devices which are capable of producing 3.3V 12mA on the output pins. These pins can also sink up to 20mA.

The boards also have a 5V pin that can be used as a current source.

I can switch a single LED using the 3.3V pins as either a source, or a sink, using a 120 Ohm (or larger) series resistor.

If, however, I need to switch two LEDs in series using a single GPIO pin, I was wondering if I can safely source from the 5V and sink to a 3.3V pin.

If this represents the 5V source, 2 LEDs (with Vf of 2.4V each) a 20 Ohm resistor connected to the pin:
5V-------|>|----|>|---- [ R 20 ]-----GPIO

When I pull the pin LOW, I am thinking the LEDs will drop the voltage by 4.8V and the 20 Ohm resistor will allow 10mA to flow.

When I pull the pin HIGH the potential difference will be just 1.7V and will be insufficient to light the LEDs.

Q1: Is my logic correct that the circuit will only apply 0.2V to the pin when it is LOW, and therefore be within the 3.3V limit?

Q2: Will harm be done to the GPIO when it is pulled HIGH. I think no current will flow.

I have read that there is debate about the ESP8266 GPIO pins being 5V tolerant, but I want to ignore that for now because if the principle is true, then the logic may also allow, say, a 12V power source (with a common ground) to perhaps be switchable without using a MOSFET so long as the 20mA limit is not exceeded.

I am also aware of voltage shifters, but I believe they only handle logic level current and would not handle 10mA for the two LEDs

Thanks in advance.

I doubt that ESP8266 pins declared as output are 5V tolerant, and would not risk making the connection you describe.

It is simple enough and completely safe to add an NPN transistor with a base resistor (say 4.7K) to sink the LED current. HIGH on the output pin turns on the transistor.

2 Likes

Say why or put two LEDs (with series current limiting resistors) in parallel.

Just don't exceed the max current of the GPIO.

a7

because the space for running the wires is so limited, I would prefer to run two instead of four.

I'm sure that makes sense.

Without seeing your mechanical concept, it is hard to believe - there is some very thin wire available that would def handle the few mA needed.

a7

Yes, safe for visible LEDs.
LEDs have a threshold voltage, even with almost no current flowing through them.
If that combined threshold is more than ~1.7volt, then you can power them from 5volt.
IR LEDs have a much lower Vf, so maybe not for two IR LEDs in series.

This is frequently done with relay modules that have an opto LED and indicator LED in series.
Leo..

1 Like

It depends on the VF of the LEDs. I would expect it to work OK. When shutting down the 3V3 be sure the 5V is off.

I do not understand that statement. What do you mean by shutting down 3V3?

When I switch the pin from 3.3V to 0 (GND) the potential difference to 5V is 5 Volts.
When I switch the pin from 0 (GND) to 3.3V the potential difference to 5V is 1.7Volts.

5V is not switched, only the drain (negative) side as described above.

That is saying when you turn off the 3V3, unplug it or however you power it down. Do not turn off the 3V3 until after the 5V is turned off otherwise you will be pumping current into the 3V3 port pin possibly damaging it.

when the pin is brought LOW it is the same level as GND. At that stage there are two LEDs and a resistor between between the +5V and the pin. This is the state in which the LEDs are on. There is no more off than that state for the GPIO pin. The pins are on the same board as the 5V pin.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.