How to wire an LJ18A3-8-Z/BX sensor with an optocoupler to a stock Ender 3?
Both diagrams are exactly the same, the difference is the +5 V that is not connected on the bottom diagram (displayed in white, labelled &quot;not used&quot;), but since your endstops do not have a +5 V pin in the socket (only ground, GND, and signal, SIG or S) you don't need to attach it. You should source the +5 V from elsewhere from your board. As the left and right side of the module are separated circuits, you need to power the board with +5 V.
Read this answer for applying 24 V.