M12 proximity sensor using grbl and arduino

Good day
I am building a CNC router using grbl and Arduino. I am using Universal G-code Sender (UGS). I added mechanical limit switches and they worked, but I want to replace them with M12 Proximity sensors NPN Normally Closed. I am struggling with the wiring. With the wiring as in my rough diagram,


the alarm is displayed on UGS and I cannot clear it. I am using the Arduino's pin 10 because that is the pin for the limit switch for one of the axes.

Have you got a common GND connection between the sensor and the Arduino ?

What voltage is the power supply and is it shared with the Arduino ?

The power supply is 12V and is separate from the Arduino.

And the common GND connection ?

That will not work. It has no GND between the M12 and the Arduino.

I am unfortunately very much a beginner with electronics and Arduino. I followed the following advice from a post that I found:

Do you mean I need to move the GND from the external power supply to the Arduino?

We need to know which prox switch you are using, brand name and exact part number or link to datasheet or seller's web page.

This is the proximity switch I am using:

Connect the blue wire to 12V ground AND Arduino GND, connect black wire to Arduino pin 10, also connect a 10k resistor from pin 10 to Arduino +5V, connect brown wire to 12V+.

1 Like

Thank you. Now it is working.