I am getting a 24V based Ender 3. From the factory, it has an aluminium bed. So I also put this LJ12 A3-4-Z/BX Inductive NPN NO 4 mm with 6-36 V operation current into the box together with a few other spare parts. Now, as I read up on these things something dawns on me: The normal input and output voltage of a simple switch is 5V, as sensors are ran on 5 V on most boards (and in digital logics). The sensors run on 6 V plus though.
I do not want to fry my machine by putting in 24V into the sensor input: What do I have to do (besides making a mount)?
The inductive sensors work better when you apply a higher voltage than 5 V. Usually they are rated for 6 - 36 V, but please do check.
To prevent frying your board when connecting the sensor to (12 or) 24 Volts you could optically isolate the 5 V and the (12 or) 24 V circuit with an OptoCoupler module:
This module uses an optical switch based on the output of the sensor and should be correctly connected:
Image of connecting an optocoupler module to the sensor and to the board
Please note that the image uses a capacitive sensor rather than a inductive sensor, both are connected similarly
Note that there are many sorts of sensors, a few are listed here. Generally speaking, the larger the diameter of the sensor, the larger the detection distance to the bed. Note that these work well with metal beds (Iron/steel better than Aluminium), but will not work for glass (capacitive sensors work on glass but are prone to drift by moisture in the air, a touch sensor may then be a better alternative).