I want to detect a binary switch state - better said a logic 1 or 0 via a PC817 optocoupler - and my question is, if both of these ways are correct:
A) Connecting the GPIO input pin via the optocoupler directly to 3.3V of the ESP32 without resistor with 4.7K and then using a pull-down resistor to GND of the ESP32. Is the pull-down resistor here even required?
B) Connecting the GPIO input pin via the optocoupler directly to GND of the ESP32 without resistor and then using a pull-up resistor with 4.7K to 3.3V of the ESP32.
Here is a schematic, I am using variant A. Does that make sense or is that dangerous to the GPIO?
I am aware that the ESP32 also has internal resistors, but I prefer an external one.
