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.
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?