Review of my "Optocoupler as Relay Board" circuit

I have made an "module" (on breadboard) with Optocoupler and Logic Level Mosfet (Type of mosfet and Optocoupler can be seen in the schematic) where my goel is to light up an 12V bulb (for testing) with Wemos D1 Mini.

It works perfectly, but i'm new to this and i need som tips and trick regards to my wiring. What can i do better etc.

I am most unsure about the 12V line that goes to the optocoupler. I do not have any resistor there now and i'm not sure if i need one. I have meassured the current to the optocoupler to 11mA.

Here is my schematic.

Your opto coupler output puts a short on the 12V supply, it does not switch the MOSFET.

Your opto coupler output puts a short on the 12V supply, it does not switch the MOSFET.

Can you explain?
I have wrote the schematic after the circuit i made that works. Off course i can have done something wrong here, but i can not see where in schematic.

In the left hand part the opto-transistor is directly across the 12V to ground, so shorting it out.
In the right hand part is is the same with the addition of a connection to the gate of the MOSFET. There is a wire from pin 1 of the connector 12V INN (I think you mean IN, an INN is a place to get a beer and food) to ground, which shorts out the gate to ground.

If your circuit works then what you have built cannot be what you have shown in the schematic.

I drawed the schematic after my circuit that works fine, so it must be my drawing is not right here. I will check when i come home from work later to day.

Thanks btw :slight_smile:

I think maybe i saw my error now.

Is this schematic better?

Your opto still shorts 12V to ground when closed.

opto short.PNG

opto short.PNG

No, you now don't have a connection to the MOSFET gate.

But do you see the net labels? One label on the mosfet gate and one label from optocoupler with same name (= connected) ?

But do you see the net labels?

I do now :wink:

I do now :wink:


The source should go straight to GND2, and the 10K resistore go to the gate!

Ciao, Ale.

Thank you very mutch! :slight_smile:

I see that now. :slight_smile:

But is it good to have an resistor between 12v and collector on the optocoupler?

But is it good to have an resistor between 12v and collector on the optocoupler?

Not needed. The max current is already limited by the Current Transfer Ratio (CTR).

Can you explain that please?

Here's a datasheet for reference.

Essentially, the max current that can flow through the transistor side of the opto is a percentage of the current flowing through the IRLED side.

The IRLED current is (3.3V - 1.2V) / 150 ohm = 14mA

Oops - you should use a higher valued resistor for the IRLED, because I think the 1/0 pin is rated 12mA max.

Anyways, if for example you're using the PC817A part, which has CTR of 80% min to 160% max, lets use 160%.

Therefore, the max current possible through the opto transistor is 14mA x 1.6 = 22.4mA.

Note - even if you connect the opto transistor across the 5V supply, this will not hurt it, the max current is limited to 22.4mA but the transistor can handle up to 50mA absolute max.

I would use 1K resistor connected in series with the IRLED, which would work for any of the parts (PC817A, PC817B, PC817C or PC817D).

Thanks for very good information! :slight_smile:

I have changed my schematic and removed Wemos. Can someone se any clear errors here?

Same as above, mosfet source have to go straight to ground! And 10K resistor to from ground to gate. And 12V in/out are inverted!

Ciao, Ale.

Replace 220R with 1K. No resistor needed from 12V to opto's collector.

Can you explain "inverted"?

I have changed the ground now... i think?