I am very new to ESP32.

I am using this optocoupler to try and power a 5V relay with an ESP32 (esphome) output pin.

Example of the wiring I did is attached.

When connected this way the optocoupler activates based on the ESP32 output (the LED turns on and off) but no matter the state of the ESP32 output, if I measure the voltage on the optocoupler, OUT pin is always at 5V and so the relay is always active.

I guess I am misunderstanding how this works, any help would be appreciated.


  • \$\begingroup\$ The picture of the coupler shows 10 kohm and a LED in series with the coupler diode. This is a design for 24 V input signals, change R1 to 100 ohm. The output circuit is inverted using a resistor to VCC. This configuration cannot drive the relay. Connect OUT to 5V and GND to the relay, leave VCC open. \$\endgroup\$
    – Jens
    Jul 7, 2023 at 19:30

1 Answer 1


There is not much information on how much current the relay needs, it's likely its above 50mA that the optocouplers max rating is.

The wiring looks fine with the exeption of there isn't a good way to know what the optocoupler actually is since there is no datasheet for it and no part info.

I would first use a power supply and set it to 5V and slowly turn up the current until the relay switches, that is how much current you will need to switch the relay and then you would need an optocoupler that can support that much current.

  • \$\begingroup\$ Thanks for the information. I guess buying from aliexpress means hardly having any datasheet :( my fault. The problem i have right now though is that i can't get the octocoupler to work as "I" expect it to ... with the wiring i draw when i measure the voltage between the "OUT" pin and "GND" on the right side of the coupler it always ready 5V regardless of the status of the coupler on the left being ON or OFF ... does it make sense ? \$\endgroup\$
    – przRocco
    Jul 7, 2023 at 17:22
  • \$\begingroup\$ You should be able to put a continuity meter between out and ground and see it switch on and off, if you can't the opto might be burned out. \$\endgroup\$
    – Voltage Spike
    Jul 7, 2023 at 17:54

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.