Electrical – Connecting NPN proximity sensor to rpi3 using reed relay

gpioproximity-sensorraspberry pi

I have an NPN LJ12A3-4-Z/BX proximity sensor that I want to use to detect water usage on a water meter that has a rotating iron disk.

To make sure I don't overpower the 3.3v GPIO inputs I want to use a reed relay SIP-1A05 to keep the 5v circuit separate. But connecting input pin 18 to the relay does not seem to work.

Do I also need to connect the ground? If so, where to? With a resistor to the relay also?

Thanks
enter image description here

Edit with updated circuit from accepted answer.

enter image description here

Best Answer

According to LJ12A3-4-Z/BX datasheet the sensor should be powered by 6-36V, so 5V may be insufficient ( brown wire = +V, blue wire = -V/GND ). Connect coil of the relay between +V and output of the sensor ( black wire ). Also connect a pulldown resistor ( a few kohm ) between pin 18 and 20.