Non-Inverting (+) Input: Wire it to the phototransistor node (the collector of Q1 after [R1]).
Inverting (–) Input: Create a reference voltage from a resistor divider:
Use [R2] (10 kΩ) from 5V to the divider node.
Use [R3] (10 kΩ) from the divider node to Ground.
Connect the divider node to the inverting input.
Output:
The comparator’s output (typically the DO pin on U1) provides a digital signal. (If necessary, add an output pull-up resistor to 5V if not already included in the module.)
Connect this output to your STM32 input.
Additional Recommendation:
Place a decoupling capacitor [C1] (0.1 µF) between the U1 VCC and Ground to help stabilize the supply voltage.
You can now use the "Apply changes" option to update your schematic with these wiring suggestions.