# Can I connect 24V direct to optocoupler?

I would like to check sensor signal on MCU. Sensor signal is 24V. Therefore, i want to use optocoupler as an interface between MCU and sensor. NC1 is going to MCU pin. My question is if i can connect 24V direct like this. There are total 4 inputs exactly same.(24V to 5V)

I have simulated this on tinkercad and it shows 11mA current flows over diode and it works without any problem. However, i don't think it is reliable to connect it like this so i want to ask how should i connect this for proper and reliable operation?

• Why's everyone so obsessed with optocouplers? They are expensive and unreliable. Just use a voltage divider. Commented Mar 29, 2021 at 6:59
• @Lundin, you can't get electrical isolation from a voltage divider. Commented Mar 29, 2021 at 7:33
• @Abd-AlRahmanMuhammad The schematic in question does not actually make use of electrical isolation at all - notice the shared grounds. (Is that intentional?) So Lundin does have a point here. Commented Mar 29, 2021 at 7:37
• @RichardtheSpacecat, Yes I did notice that there is no electrical isolation indeed, but I blame the author for that mistake, I was talking with Lundin in general about what I can take from an optocoupler, not what I can take from it in this case. Commented Mar 29, 2021 at 7:42
• @Lundin, I am sorry I did not notice your first comment. As mentioned in my reply to Richard, I am not talking about this particular case, but I was talking in general. You were say why is everyone obsessed with optocouplers, so you were generally speaking too, that's why I was replying in general. I hope I made my point clear this time. Thank you Commented Mar 29, 2021 at 7:47

No. As indicated by the symbol, the opto-transmitter is an infrared LED with a typical forward voltage, Vf, of 1.4 V. Like any LED in a similar situation a series resistor is required to limit the current. In your case you probably want 10 mA through the LED so $$\ R = \frac V I = \frac {22.6} {10m} = 2k2 \$$.

A few tips:

• Draw your schematics so that higher voltages are at the top of the page and current flows from top to bottom. i.e. Invert your opto-isolator.
• Generally signal flow should be from left to right. i.e. LED (the input) on the left, output transistor on the right.
• GND symbols should point down to ground.

If you are interested, Rules and guidelines for drawing good schematics is well worth a read.

No, direct connection to 24V is not OK. You need a resistor for current limiting.

Well, as an answer for your question's title, yes you can. But after seeing the schematic, the answer has changed to no you can not.

The optocoupler's input is an LED, any LED is a diode, which has a forward voltage (Vf) and has a maximum current (Imax), but generally speaking, these small LEDs you use with microcontrollers generally have a maximum current of 20mA, it is better anyway to check the datasheet of your LED or your optocoupler in this case.

Now the problem is you are appying (+24V) which everyone can guarantee is greater than the (Vf) of the LED, which will result in very high current that would lead to the destruction of the LED, hence the optocoupler would be useless.

A cheap, yet suitable solution is to add a current limit resistor which needs to dissipate the rest of the voltage and limit the current to 20mA or less, as mentioned, the datasheet will give you the range you can work in, but I will just go with 10mA, and a forward voltage of 2V, just to simplify the calculations in this case. R = V / I = (24 - 2) / (10mA) = 2.2Kohm, that is a 2.2Kohm resistor in series with the LED, needless to say, it wont actually matter if you put it before or after the LED, in other words it does not make a difference whether the current passes through the LED first or the resistor first.

Now afer we solved the first problem, let's talk about a second/side problem, do you know what is the advantage of using an optocoupler? The main advantage is having electrical isolation between the two sides (input and output), you clearly are not taking this advantage, so you paying extra money, if you do not care about electrical isolation (which I will not go into details about it), I suggest you use a normal transistor.

Thank you and good luck.

Add one of the following resistors between your VDC and the anode of the diode of the optocoupler:

1.2 kOhm in case you have +5 VDC
4.7 kOhm in case you have +12V VDC
6.8 kOhm in case you have +24V VDC

as an additional protection you can connect 2 Diodes in series between Pin1 & Pin2 of the Opto with the Anode towards Pin 1. This would ensure only 1.4V max between Pin1 & 2.

I'm currently designing a 24V input, and I just have to point out that the power dissipation of a series resistor that drops 22V at 0.01A is 0.2W, which is not insignificant and should be taken into account in resistor selection and thermal design.