Inductive proximity sensor

Hello !
I'm using inductive proximity sensor( NPN 6 to 36VDC 300mA 4mm) to detect metals. I connect an arduino uno (powered by my pc) with the sensor(power with 9v). I write a code that show me if metal is detected or not. Unfortunately it seems that even if nothing is detected the code is still running, even if I take off the sensor. Is it a connection problem? Must I use other component like resistors, ect ? Or just the code? Can I get help please?

The code :

int sensor = 10;

void setup() { 
  Serial.begin(9600);
  pinMode(sensor, INPUT);
}

void loop() {
  int state = digitalRead(sensor);
  if (state == HIGH) {
    Serial.println("Metal is detected");
    delay(2000); 
  } 
  else {
    Serial.println("No metal");
    delay(2000); 
    }
  }

Try putting a 10K resistor between the output of the sensor and GND.

it doesn't work :frowning_face:

Can I have a schematic please?


the PiR has same terminals that inductive sensor

What PIR model is it?

I'm working with inductive proximity sensor( NPN 6 to 36VDC 300mA 4mm). I just use the PIR to build a schematic because PIR has the same terminals than my sensor

Well, what is the exact model of the inductive proximity sensor?

Inductive Proximity Sensors NPN

The sensor outputs a LOW signal when it detects metal, and 6v isn't compatible with arduino without a resistor or logic converter.

As a newbie :sweat_smile:, I only understand the suggestions. what do I have to do?

Good schematic, but there is NO connection of PIR ground to the Arduino ground.

1 Like

Provide a lot more specific information, that we may help.

Thank you

Hello !
I'm trying to connect 4 inductives proximity sensors NPN with my arduino uno.
I already make connect with 1 sensor according to this schematic


How can I complete the assembly ? May I use a other components like resistors, etc?

Your schematic shows a PIR (passive infrared detector) - that's not "inductive".

Oh sorry, I didn't find the proximity sensor for the schematic. Fortunately it has the same terminals than the PIR. It's the fact that I decide to use it.

  • Give us WEB links to your hardware.

Try to imagine that not everyone has a TinkerCAD account.

3 Likes

Basically :sweat_smile:
I'm sorry.