Using an optocoupler with a ESP 32

I am intending to use the output from an ESP 32 to the input of a 4N25 optoisolator.
The voltage on the pin of the ESP 32 shows 3.3V
The max voltage of the 4N25 shown on the data sheet is 1.2V It also shows a max current of 80ma
I assume I should try to keep the current down to around 60ma. Is this correct?
3.3 / .006 = 550. Should I put a 550 ohm resistor between the pin of the ESP 32 and the input of the 4N25?

I want to use the output of the 4N25 to power a device that requires 12V. If I connect it to a 12v source, using a multimeter between them, it shows about 64ma of current. Should I put a resistor in that circuit?

This is a first for me, so I’m not sure of anything!

Whatever microcontroller you’re using, look in the datasheet for an I/O pin current limit figure. It’ll probably look something like this:

That’s all the current you’re permitted to draw from the pin; if you’re driving a diode, such as found in an optocoupler input, pick a resistor to yield that current or less based on the I/O supply voltage and the diode Vf. Watch the decimal points: 60mA is 0.060A, not 0.006A.

The 4N25 is an optoisolator designed for data transmission,e.g. controlling tiny currents at high speeds. If you look at the transfer characteristics of a sample device of that type, you’ll find that you’re only guaranteed to get 20% as much current flowing through the output as you draw through the input diode, and that’s with 10V still appearing across the output transistor. Stated differently, a 4N25 is a rather crummy choice for any sort of direct-switched power application.

Similar devices better suited to the control of larger currents at lower speeds will typically be found classified as Solid State Relays. There’s definitely devices in that family which would be adequate for the task.

Nope; so doing would cause unwanted losses, in the same basic way that trying to supply a jackhammer through an 1/8" air line isn’t likely to give good results.

1 Like

Thanks for your reply! Sorry about the .006 typo!

I am looking through several data sheets and am going to try to figure this out. I have an unrelated issue that just came up, so it’ll probably take a couple of days until I can get to this. I’ll post again with my findings to make sure I have it right.


Warning, you have used values from the two very different sections of the data sheet!

The ABSOLUTE MAXIMUM RATING section is never for operational specifications, it is simply the maximum values that are guaranteed to not cause irreversible damage to the component. The component might not function in any useful way at those values and it will shorten the life being exposed to those values.

From the ABSOLUTE MAXIMUM RATING footnote in Vishay’s data sheet:

Stresses in excess of the absolute maximum ratings can cause permanent damage to the device. Functional operation of the device is not implied at these or any other conditions in excess of those given in the operational sections of this document. Exposure to absolute maximum ratings for extended periods of the time can adversely affect reliability.

Down in the normal specifications you’ll see the values that are meant to be used for normal operation. For the LiteOn & Visahy versions of the part, the current used is 10mA to meet the other electrical specifications given.

1 Like

OK. This idea with the 4N25 isn’t going to work!
Let me close this thread and start all over with a new one. Thanks for your help.