your sensor should do the job. It will get wired for 24VDC The output of the sensor will switch the lower voltage provided that 24VDC power supply and the 5VDC have common grounds. Circuit shows an NPN type sensor
post photo of sensor and give more detail as to the circuit it will connect to