magnetic rotary encoder 0.3V output voltage

I have a 24V DC motor with a magnetic rotary encoder. The encoder has a 5V supply voltage. The datasheet states that it has an output voltage of 300-700mV. I have also measured it, and it gives around 0.5V. I want to interface this encoder with an STM32 microcontroller, so I want to convert it (reliably) to 3.3V. But I don't really know how. Since the datasheet states a 300mV minimum voltage, I want to build a circuit, that "turns on" at 0.25V, it is "off" below and "on" above, and gives me a clean square signal.

My first though was a transistor operated as a switch, but 0.3V is not enough for a BJT transistor's operation. Then I was thinking about a MOSFET circuit like this one, with an N-channel enhancement MOSFET:

But I have no experience with such circuits. Could this work with just 0.25V threshold? Or do I have to amplify it? What MOSFET and resistor values do I choose?

Or what other solution would be better in this situation?

MCU: STM32F101R8T6 (GPIO PC8, PC9)

• @Marcell Juhász, Ah there is some misunderstanding. The specified output voltage of 300-700mV, and you measured 0.5V is the "active" or "triggered" signal. When not active or not triggered, the output voltage is roughly Vcc. If you use Vcc = 5V at the output side, the signal is 5V not active, 0.3 to 0.7V (or 0.5V in your case). What you might not be aware, that the the 20mA current loop protocol is used in your encoder. You might like to google "20mA" to learn more. Eg, 4-20mA Current Loop Primer - DMS murata.com/-/media/webrenewal/products/power/appnote/… Commented Mar 5, 2021 at 12:14
• The output low voltage is actually the Vce(sat) voltage of the NPN BJT switch in the datesheet. The output high voltage is your Vcc, can be as high as 15V. If you mcu/sbc is 5V, then us 5V Vcc. Commented Mar 5, 2021 at 12:16
• ohh okay, thank you very much, I will look up what you wrote! Commented Mar 5, 2021 at 12:17