My question might be already answered but I have some problem with resolving it. I'm using PC817 Opto-Coupler to turn on a relay. My VCC voltage is about 4.2 volts and the MCU is an STM32F4 with 3.3v voltage level. When I set the MCU pin (M_Relay) low, it seems that Opto doesn't turn on. I measure the voltage of the input diode(Opto input) and it was about 1v which is below the minimal voltage. I'm not sure about what value should I use for R56.

enter image description here


1 Answer 1


From the data sheet, Forward diode voltage is 1.2V, and it seems to want 20mA.

Thus, the resistor has 4.2-1.2=3.0V across it. For 20mA, Ohm's law says you want 150 Ohms.

There will be some current when you have the input at 3.3V, and it remains to be seen if it's too much for an "off".

You could avoid the issue of the off current by grounding pine 2 and driving the LED from the MCU I/O pin idrectly, if it can provide 20mA (in fact, you'd already be sinking 20mA the way you're doing it now). In that case, the voltage drop across the resistor would be 3.3-1.2=2.1V, and you would use a resistor of 100 Ohms. If the MCU can't do 20mA, you could probably configure the pin as open collector.

  • \$\begingroup\$ Yes first I used an led then I unmounted it because I thought that it drops the voltage across Opto's diode and I removed it. So let me solder it and test it. \$\endgroup\$ Commented Nov 28, 2018 at 16:07
  • 1
    \$\begingroup\$ @MasoudR. The LED is the optocoupler!! \$\endgroup\$ Commented Nov 28, 2018 at 16:11
  • \$\begingroup\$ Ah so you mean I should not put an led series to opto's led? \$\endgroup\$ Commented Nov 28, 2018 at 16:21
  • \$\begingroup\$ @MasoudR. -- no you should not. Just a resistor of the correct size. \$\endgroup\$ Commented Nov 28, 2018 at 16:24
  • \$\begingroup\$ I used a 120 Ohm resistor but it didn't work. Is my Opto broken? I tried to check the diode with a multimeter and it shows about 0.9v. \$\endgroup\$ Commented Nov 28, 2018 at 16:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.