Use of Capacitive Proximity Sensor

I've been having problems on how to interface the signal of the LJC18A3-H-Z/BY. Which runs HIGH on signal when something is detected. I tried running the signal through a resistor pull-up using a 10k resistor. The voltage of the signal of the sensor wasn't enough to make the signal back to the arduino be HIGH. I've done this because I have the pin 2 on INPUT and as you may know may cause electrical noise. INPUT_PULLUP was the thing I don't know if possible because the sensor signals high when something is detected. I am a beginner at this. Sorry if I was wrong or didn't know something. Thank you!

Quick Specs:
Product Name: Proximity Switch
Specifications Model: LJC18A3-H-Z / BY
Tip diameter: ~15mm
Dimensions: 70 x 30 mm
Detection Method: Capacitive
Output Type: PNP, NO
Detection Range: +- 10 mm
Detecting: metal and non-metallic such as plastic, glass, water, oil
Operating voltage: DC 6 to 36V
Weight: 84g

Code:


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

void loop() {
    unsigned long int capvalue = digitalRead(capsensor);
    
    if(capvalue == 0) {
        Serial.println("0");
    } else {
        Serial.println("1");
    }
   // Serial.println(capvalue);
    delay(500);
}

Pin 2 is connected to the signal of the sensor. Thats it!

Please post a link to the specs of your sensor, a schematic showing us how you wired it and your code (in code tags). Please read the forum guide in the sticky post at the top of the forum if you are unsure how to post any of these things.

I added it!

Thanks for adding the code. Now please add the link and schematic as requested.

Do I still need schematic? I only have the signal of the sensor connected to Pin 2/D2. And the sensor is connected to a 12v power supply. I tried to make it work on an led, it turned on when it detected something.

Only if you want the forum to be able to help you. If you do not post it, we will have to rely on our crystal balls. I have to tell you, they don't work so good. Hand-drawn schematic is OK.

Read the forum guide in the sticky post at the top of the forum section. This will tell you what to post and why you need to post it.

1 Like


Is this okay?

Good enough to spot the problem.

There is no common ground between the Arduino and the 12V supply. Without that common ground, the Arduino cannot read the signal.

This may mean that a 10K pull-down resistor is needed between the Arduino pin and ground.

What voltage does the sensor output? If it outputs anything above 5V, that could damage the arduino. Measure the output voltage with your multi-meter before you connect it to the arduino pin.

1 Like

I tried it with the arduino nothing seems to break. I tried to analog read it on the arduino, it measured around 1023.

If you are supplying the switch with 12 volts, it will put near 12 volts on it's output wire, you need a voltage divider or switching transistor. Do not connect directly to Arduino input pin.

Can I use resistors? I saw people using it on proximity sensors.

Which Arduino, 5 volt or 3.3 volt?

Arduino Uno, 5v

Is this a joke or something? I don't really have a multi-meter as it just broke recently.

Can you understand this quick drawing?

Yes, I understand it, but when I use gnd from the 12v to the arduino. The sensor seems to heat up.

Also wouldn't the 10k resistor heat up because gnd is coming from 12v. I accidentally added a 220 ohm resistor to the gnd from the 12v and it heated up pretty fast.

I did try this, still the arduino detects as 0. But when theres no 18k, it works but when it detects something, it never leaves at HIGH.

If wired correctly, 12V output from the sensor would drive 0.000428 Amps through the series connection of R1 (18000Ω) and R2 (10000Ω), total 28000Ω, Power dissipated by resistors would be about 0.005 Watts or 5 milliWatts, not enough to warm a flea's behind. That current flowing through R1 (18k) would cause a voltage drop of about 7.7V and P of 3.3mW, through R2, 4.28V and 1.8mW.
Are you sure you have the right components and wiring is correct?

What are the wire colors on your switch? What color is connected to what?

I used 16k which is the nearest resistor I have.

Blue to GND
Brown to 12V
Black to the 16k