Connecting a 3-wire inductive sensor to arduino

We are building a tachometer for our Mini Baja car with a 3-wire inductive sensor connected to arduino but we're having some issues. The sensor is supposed to work with a metal wheel with a small gap in it.

It's the OMRON proximity sensor E2B, 3 wires.

We can't get arduino to receive any response from the sensor. We know it's working because it has an LED on its back and it turns on whenever it's in contact with a metal. We've also added an external LED to the circuit to turn on along with that built in one.

At first we're just running a simple test to see what arduino comes up with when it's in contact with a metal or not.

The code is:

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

void loop(){

Serial.println(digitalRead(8));
delay(500);

}

The circuit is attached

IMG_4847 (1).JPG

Which version of E2B sensor are you using? NPN or PNP?

What is your voltage source? If you are using 10-30VDC supply and PNP version, you have probably destroyed the input on the Arduino. If NPN, it won't work the way you have it wired either.

Please also use the code tags (Looks like </>) for posting your code.

Our voltage source is 9V and it's NPN.
We've added a 1K resistance to the circuit to drop the voltage to 5V and not damage arduino.

According to the datasheet, 10V is the minimum. The output may not be turning on fully. Where is the 1k resistance? Please post a complete diagram. Have you verified a 5V signal to the Arduino?

Can you please tell me what would you do to wire that sensor to Arduino?

I might be wrong but I thought it was supposed to be a simple thing. Feed the sensor with 10-30V and use something to drop the voltage to 5 so Arduino won't be damaged.

Even with 9V the LED on the sensor turns on when in contact with metal.

Post a circuit diagram of how you wired it and we will tell you how to fix it.

Our circuit is attached. I've used a servo motor because I couldn't find a 3-wire inductive sensor on Fritzing.
The resistances are 12K and 8K but the color code on them show only 12 and 08. The software doesn't allow us to set a value with more than 3 digits.

The codes on arduino are the same I've posted before.

A hand drawn schematic is ALWAYS better than a fritzing diagram, and there are many problems with the one you posted. However it does suggest that you forgot to connect all the grounds together. Please post a corrected, hand drawn schematic diagram.

Read this NPN sensor signal> Arduino UNO; seeking a solution for novices - Sensors - Arduino Forum