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.
PerryBebbington:
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.
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).