0
\$\begingroup\$

I want to know if my high side logic from 3.3 volt esp32 is right about linking a led on a gpio output to an optocouplerenter image description here

\$\endgroup\$
6
  • 1
    \$\begingroup\$ Are you sure you even need the optocoupler there? In your schematic your ESP and the 12V rail both have the same GND reference. The optocoupler is only required if you want to seperate the esp from the 12V rail. \$\endgroup\$ Commented Oct 13, 2023 at 11:36
  • \$\begingroup\$ sorry about shematic i have made a mistake the GND are not sharing \$\endgroup\$ Commented Oct 13, 2023 at 11:51
  • \$\begingroup\$ the are 2 ground separate \$\endgroup\$ Commented Oct 13, 2023 at 11:51
  • \$\begingroup\$ @ScottSeidman the load is isolated via the relay, is it not? \$\endgroup\$ Commented Oct 13, 2023 at 11:53
  • \$\begingroup\$ Looks OK to me. What is the relay coil resistance? \$\endgroup\$
    – Jens
    Commented Oct 13, 2023 at 13:39

1 Answer 1

0
\$\begingroup\$

This Answer might not be 100% complete, but here are 2 things I'd change:

According to the PCF817 datasheet, the nominal forward current is 20 mA with a forward voltage of 1.2 V. That means R11 is way too large. The drop at R11 is 3.3 V - 1.2 V = 2.1 V @ 20 mA, so R11 should be ~ 105 Ohm.

The way you wired up the output side will probably not work correctly. When the optocoupler is off, your transistor's base is floating, which should be avoided. I'd probably do something like this:

schematic

simulate this circuit – Schematic created using CircuitLab

That way the Relay should be default on and triggering the opto pulls Q5's base to GND -> state switches to off.

Be aware though, I haven't tried/tested/simulated this, so it might not work perfectly, but that's where I'd start.

\$\endgroup\$
1
  • \$\begingroup\$ The ESP32 GPIO cannot deliver 20 mA and 2 mA are enough as forward current for the coupler. This would provide > 1 mA base current and up to 100 mA relay coil current in the OP's original circuit. \$\endgroup\$
    – Jens
    Commented Oct 13, 2023 at 13:37

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.