TL; DR: I need a circuit capable of handling input voltages from 24V to 3.3V (with a 10mA/5mA maximum current) and delivering 3.3V to the microcontroller (ESP32) input.
Recently, I've been working with the EPS32 microcontroller. And this project in specific requires signals from different sources, with different maximum output voltages: 5V, 24V and 3.3V. The frequency wouldn't be more than 100KHz.
My signal sources can provide up to 10mA, but a 5mA limit would be more confortable for me to work with. Galvanic isolation isn't a requirement, but it would be interesting!
I searched on the web for circuits to implement in the project, but almost every one that I could find, could only handle a single specific voltage. The majority of the designs I found were based on the classical optocoupler circuit, with a current limiting resistor, calculated for a certain voltage.
In fact, I found an Electronics Stackexchange question that was almost exactly what I needed (How is this 5-24V input circuit working?), but I don't have access to any JFETs in my local store, also, I couldn't find any MOSFET to effectively replace this JFET.
I was thinking if OPAMPs could do this job, but I am not sure if this is a good practice.
Any help will be very appreciated!
PS.: Sorry if my question doesn't express my current effort in the project, as it doesn't contain any circuit/design attempt made by me, but I am really lost with this part of my project! So I couldn't figure out any decent circuit.