Electronic – Proximity sensors interfacing with microcontroller

microcontrollerproximity-sensorsensorstm32transistors

I'm trying to connect this proximity sensor GX-H8A to interface with my microcontroller STM32L4R5. I just want to make sure if my design will work and will not damage the micro.

enter image description here

I'm planning to connect the Brown wire to 24VDC, Blue wire to Ground, and the Black wire to the input signal on my microcontroller, and a 3.3V pull up with a 10K resistor on the Black wire as well. So when the sensor detects the object, it will get pulled to ground and the micro will receive a 0 signal.

Is this configuration and theory correct? I'm scared that somehow the 24V will got connected to the microcontroller and damage it, and I'm not sure why they connected the Output node with the 24V node in the circuit diagram.

Thanks.

Best Answer

The GX-H8A has NPN type open-collector output, so it should work exactly as you described.

The 10k pull-up can make the signal rise quite slowly, but it should not matter much, I just mention it so you can change to stronger pull-up if it is a problem. If the rise time is not important and the internal weak pull-up of the MCU is enough, you can also try without external pull-up.