# Use of Capacitive Proximity Sensor

**URL:** <https://forum.arduino.cc/t/use-of-capacitive-proximity-sensor/1213562>\
**Category:** Sensors\
**Created:** [January 20, 2024, 11:54am UTC](https://forum.arduino.cc/t/use-of-capacitive-proximity-sensor/1213562 "2024-01-20T11:54:18Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![magerusesthis](https://avatars.discourse-cdn.com/v4/letter/m/3d9bf3/32.png) [@magerusesthis](https://forum.arduino.cc/u/magerusesthis)\
**Post date:** [January 20, 2024, 11:54am UTC](https://forum.arduino.cc/t/use-of-capacitive-proximity-sensor/1213562/1 "2024-01-20T11:54:18Z")

</div>

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:

```const

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!

---

<div class="post-metadata">

**Author:** ![PaulRB](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/paulrb/32/216330_2.png) [@PaulRB](https://forum.arduino.cc/u/PaulRB)\
**Post date:** [January 20, 2024, 12:04pm UTC](https://forum.arduino.cc/t/use-of-capacitive-proximity-sensor/1213562/2 "2024-01-20T12:04:46Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![magerusesthis](https://avatars.discourse-cdn.com/v4/letter/m/3d9bf3/32.png) [@magerusesthis](https://forum.arduino.cc/u/magerusesthis)\
**Post date:** [January 20, 2024, 12:13pm UTC](https://forum.arduino.cc/t/use-of-capacitive-proximity-sensor/1213562/3 "2024-01-20T12:13:52Z")

</div>

I added it!

---

<div class="post-metadata">

**Author:** ![PaulRB](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/paulrb/32/216330_2.png) [@PaulRB](https://forum.arduino.cc/u/PaulRB)\
**Post date:** [January 20, 2024, 12:16pm UTC](https://forum.arduino.cc/t/use-of-capacitive-proximity-sensor/1213562/4 "2024-01-20T12:16:05Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![magerusesthis](https://avatars.discourse-cdn.com/v4/letter/m/3d9bf3/32.png) [@magerusesthis](https://forum.arduino.cc/u/magerusesthis)\
**Post date:** [January 20, 2024, 12:25pm UTC](https://forum.arduino.cc/t/use-of-capacitive-proximity-sensor/1213562/5 "2024-01-20T12:25:52Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![PaulRB](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/paulrb/32/216330_2.png) [@PaulRB](https://forum.arduino.cc/u/PaulRB)\
**Post date:** [January 20, 2024, 12:32pm UTC](https://forum.arduino.cc/t/use-of-capacitive-proximity-sensor/1213562/6 "2024-01-20T12:32:20Z")

</div>

> [@magerusesthis](#):
>
> Do I still need schematic?

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.

---

<div class="post-metadata">

**Author:** ![magerusesthis](https://avatars.discourse-cdn.com/v4/letter/m/3d9bf3/32.png) [@magerusesthis](https://forum.arduino.cc/u/magerusesthis)\
**Post date:** [January 20, 2024, 1:09pm UTC](https://forum.arduino.cc/t/use-of-capacitive-proximity-sensor/1213562/8 "2024-01-20T13:09:11Z")

</div>

![12v_20240120_210720_0000](https://europe1.discourse-cdn.com/arduino/original/4X/3/a/6/3a6e1c8506dcd1f3d058c356d951671af84562ef.png)  
Is this okay?

---

<div class="post-metadata">

**Author:** ![PaulRB](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/paulrb/32/216330_2.png) [@PaulRB](https://forum.arduino.cc/u/PaulRB)\
**Post date:** [January 20, 2024, 2:33pm UTC](https://forum.arduino.cc/t/use-of-capacitive-proximity-sensor/1213562/9 "2024-01-20T14:33:31Z")

</div>

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.

> [@magerusesthis](#):
>
> Output Type: PNP, NO

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

> [@magerusesthis](#):
>
> I tried to make it work on an led, it turned on when it detected something.

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.

---

<div class="post-metadata">

**Author:** ![magerusesthis](https://avatars.discourse-cdn.com/v4/letter/m/3d9bf3/32.png) [@magerusesthis](https://forum.arduino.cc/u/magerusesthis)\
**Post date:** [January 20, 2024, 8:09pm UTC](https://forum.arduino.cc/t/use-of-capacitive-proximity-sensor/1213562/10 "2024-01-20T20:09:25Z")

</div>

> [@PaulRB](#):
>
> Measure the output voltage with your multi-meter before you connect it to the arduino pin.

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

---

<div class="post-metadata">

**Author:** ![JCA34F](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/jca34f/32/340148_2.png) [@JCA34F](https://forum.arduino.cc/u/JCA34F)\
**Post date:** [January 20, 2024, 8:25pm UTC](https://forum.arduino.cc/t/use-of-capacitive-proximity-sensor/1213562/11 "2024-01-20T20:25:02Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![magerusesthis](https://avatars.discourse-cdn.com/v4/letter/m/3d9bf3/32.png) [@magerusesthis](https://forum.arduino.cc/u/magerusesthis)\
**Post date:** [January 20, 2024, 8:28pm UTC](https://forum.arduino.cc/t/use-of-capacitive-proximity-sensor/1213562/12 "2024-01-20T20:28:53Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![JCA34F](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/jca34f/32/340148_2.png) [@JCA34F](https://forum.arduino.cc/u/JCA34F)\
**Post date:** [January 20, 2024, 8:55pm UTC](https://forum.arduino.cc/t/use-of-capacitive-proximity-sensor/1213562/13 "2024-01-20T20:55:47Z")

</div>

Which Arduino, 5 volt or 3.3 volt?

---

<div class="post-metadata">

**Author:** ![magerusesthis](https://avatars.discourse-cdn.com/v4/letter/m/3d9bf3/32.png) [@magerusesthis](https://forum.arduino.cc/u/magerusesthis)\
**Post date:** [January 20, 2024, 10:05pm UTC](https://forum.arduino.cc/t/use-of-capacitive-proximity-sensor/1213562/14 "2024-01-20T22:05:16Z")

</div>

Arduino Uno, 5v

---

<div class="post-metadata">

**Author:** ![magerusesthis](https://avatars.discourse-cdn.com/v4/letter/m/3d9bf3/32.png) [@magerusesthis](https://forum.arduino.cc/u/magerusesthis)\
**Post date:** [January 20, 2024, 10:43pm UTC](https://forum.arduino.cc/t/use-of-capacitive-proximity-sensor/1213562/16 "2024-01-20T22:43:42Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![JCA34F](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/jca34f/32/340148_2.png) [@JCA34F](https://forum.arduino.cc/u/JCA34F)\
**Post date:** [January 20, 2024, 11:22pm UTC](https://forum.arduino.cc/t/use-of-capacitive-proximity-sensor/1213562/17 "2024-01-20T23:22:05Z")

</div>

Can you understand this quick drawing?

 ![Scanned Document](https://europe1.discourse-cdn.com/arduino/original/4X/c/3/c/c3c91be43e6ca2a7dee22747deb6f0fa8151ec34.jpeg)

---

<div class="post-metadata">

**Author:** ![magerusesthis](https://avatars.discourse-cdn.com/v4/letter/m/3d9bf3/32.png) [@magerusesthis](https://forum.arduino.cc/u/magerusesthis)\
**Post date:** [January 21, 2024, 12:17am UTC](https://forum.arduino.cc/t/use-of-capacitive-proximity-sensor/1213562/18 "2024-01-21T00:17:53Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![magerusesthis](https://avatars.discourse-cdn.com/v4/letter/m/3d9bf3/32.png) [@magerusesthis](https://forum.arduino.cc/u/magerusesthis)\
**Post date:** [January 21, 2024, 12:48am UTC](https://forum.arduino.cc/t/use-of-capacitive-proximity-sensor/1213562/19 "2024-01-21T00:48:32Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![magerusesthis](https://avatars.discourse-cdn.com/v4/letter/m/3d9bf3/32.png) [@magerusesthis](https://forum.arduino.cc/u/magerusesthis)\
**Post date:** [January 21, 2024, 3:50am UTC](https://forum.arduino.cc/t/use-of-capacitive-proximity-sensor/1213562/20 "2024-01-21T03:50:40Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![JCA34F](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/jca34f/32/340148_2.png) [@JCA34F](https://forum.arduino.cc/u/JCA34F)\
**Post date:** [January 21, 2024, 4:10am UTC](https://forum.arduino.cc/t/use-of-capacitive-proximity-sensor/1213562/21 "2024-01-21T04:10:10Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![magerusesthis](https://avatars.discourse-cdn.com/v4/letter/m/3d9bf3/32.png) [@magerusesthis](https://forum.arduino.cc/u/magerusesthis)\
**Post date:** [January 21, 2024, 4:42am UTC](https://forum.arduino.cc/t/use-of-capacitive-proximity-sensor/1213562/22 "2024-01-21T04:42:27Z")

</div>

> [@JCA34F](#):
>
> Are you sure you have the right components and wiring is correct?

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

> [@JCA34F](#):
>
> What are the wire colors on your switch? What color is connected to what?

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

[Next page](https://forum.arduino.cc/t/use-of-capacitive-proximity-sensor/1213562.md?page=2)
