Electronic – Common cathode RGB LED from 3.3v

bjtdriverled

I have an RGB LED (common cathode) that I would like to trigger from the GPIO pins of an ESP8266 (3.3v). The device I am using (Wemos pro mini D1) has a 5V supply which I was planning on controlling via a transistor (I have some 2N3904).

From some reading I understand this can be achieved as follows (and I'm happy with the reasoning why):

enter image description here

Credit: here

However, I wanted to know if this was achievable using just one BJT? I've seen some people suggests just using one NPN and the load on the emitter and no resistor on the base but when I tried this out I had extremely low Ib which was insufficient to fully "switch" the BJT.

Best Answer

I wanted to know if this was achievable using just one BJT?

Not so easily in your case, the issue is that the ESP8266's output is either 0 V or 3.3 V. Relative to the +5 V rail (where the switching transistor would be) that gives either 5 V - 0 V = 5 V or 5 V - 3.3 V = 1.7 V across the input of the transistor.

Switching on/off an NPN using 0 or 3.3 V can be done directly (as per your suggested 2 transistor circuit).

Switching on/off a PNP (since we switch the +5 V side) using 1.7 V or 5 V is less straightforward. It could be done for example using a zener diode to subtract about 1.7 V but it is cumbersome. The 2 transistor solution is just as easy, likely costs the same (only standard components needed, no zener needed) and more fail safe.