How to connect an industrial 24V sensor to a 3.3V input Raspberry Pi pin?
From the online data sheet for your sensor the outputs are described as follows:



A PNP output from a sensor means that the output will have an active switch element that will pull the output signal toward the supply voltage when in the "high" logic state. When in the other state the active switch output will shut off and the output will either become open circuit or will be passively pulled down via some internal resistance. (In my experience it is typical that the output will not have any internal pulldown resistance at all and it is up to the user application to supply any such required circuitry).

You will require some interface circuitry to be able to connect this to your MCU inputs. There are a number of options for doing so:


Two resistor voltage divider from output to GND to divide the active high output of the sensor from 22V -> 24V down to ~ 3V.
Use an NPN transistor with a resistor from its base to the sensor output. Emitter connected to GND and collector to MCU input and pullup resistor to MCU supply voltage.
One resistor from sensor output to the anode input of an optocoupler. Cathode of optocoupler to GND.


Note that the MCU board that you are using is not one directly designed for use in an industrial type application and as such does not come with inputs conditioned for typical industrial device outputs. If you were using a commercial device such as a small PLC (programmable logic controller) it would have inputs that could directly interface to the sensor output with just wires. In your case you will have to provide the necessary signal conditioning external to your MCU board. In addition to the signal interface options I described above your circuitry will also have to deal with protection of the MCU inputs against ESD and possible common mode voltage difference in GND levels between MCU location and sensor location if they are wired far apart.