Currently I am trying to build a circuit, with the goal of triggering a pin of an ESP8266 from varying input voltages (in the range of 5 to max 15 volts it should get triggered). Also the input should be seperated from the ESP.
What I was thinking to do was:
- Use an optocoupler for the input voltage (currently thinking about the pc817)
- Calculate the resistor so that min voltage and max voltage would work (current range of the pc817 is 20mA – 50mA, and Voltage Range is 1.2 (standard) to 1.4):
- 15V: (15V – 1,2V) / 0,05A = 276 ohm (already calculated for absolute max current)
- 5V: (5V-1,2V) / 0,02A = 190 ohm
So which resistor should I use to allow 5-15V in this optocoupler? Or is there any better circuit option/better optocoupler that allows something like this to be achieved?