Electronic – Designing a transistor switching circuit with opto-isolation

analogcircuit-designopto-isolatortransistors

I am working on a project where I want to switch a 12V DC LED strip(power consumption 300mA) using ESP32 having a complete isolation between LED strip power source. I came up with following circuit.

enter image description here

Here optocoupler is PC817,
transistor is NPN 2n2222,
LED-STRIP_ESP_14 is the esp32 GPIO pin,
GND2 is esp32's GND,
GND1 is common for 5V1 and 12V+,
I'm using 5V at the phototransistor side of the pc817 because I have 5V readly available on another part of same circuit.

So, when LED-STRIP_ESP_14 goes HIGH, I want LED_STRIP to glow mode and when LED-STRIP_ESP_14 goes LOW, I want LED_STRIP to off.

Is this circuit designed correctly for the purpose?

Best Answer

The PC817 has a CTR of 50% minimum at 5mA, it's about half that at 0.2mA so you can only count on about 50uA going to the base. You should also derate for aging and temperature, which makes it even worse, but let's ignore that for now.

That will support the transistor switching about 1mA with it well saturated (Ic/Ib = 20), which is about 1/300 of your desired load current.

I suggest boosting up the LED current to at least 5mA, and using a MOSFET rather than a wimpy little signal BJT. You can use the +12V supply (the PC817 is rated at 35V) so it does not have to be a logic-level MOSFET.