Capacitive sensor library arduino problem

Hello and srry for asking this problem :confused:

So i want build a touch sensor to control my servo. I want servo move to 120 degree when touch & move to 0 degree when not touched.

(capacitive sensor library). I use pin 6 as sendpin & 9 as receivepin , there is resistor 3.3M and touch sensor with foil in between.

My Problem is : the value from the sensor not stable and i need servo keep the position when touched (which is 0 degree).

  • I use battery with supply 5V (Power Bank) for arduino Uno Board & for servo i use another supply (6V), the ground is all connected each other.

There is any solution for this problem?, thank you very much

My Problem is : the value from the sensor not stable

Yes that is the problem with that libiary the values are not stable.
Even with a dedicated capacitance sensor chip you will not get stable values. This is because your circuit is not physically stable. Wires move and it is not in a fixed position.

Sorry this is a trap that fools many a beginner.

It's not a software problem, it's a hardware problem instead. Cut your sensor in two, and connect one part to the Arduino Gnd. The additional ground plane is required in detail with battery operation. For testing you can touch the Arduino Gnd with one hand, then approach the sensor with your other hand.

Grumpy_Mike:
Yes that is the problem with that libiary the values are not stable.
Even with a dedicated capacitance sensor chip you will not get stable values. This is because your circuit is not physically stable. Wires move and it is not in a fixed position.

Sorry this is a trap that fools many a beginner.

is there any way for this sir or the other way?, atleast i could move servo when the value become high and go otherwise when low

DrDiettrich:
It's not a software problem, it's a hardware problem instead. Cut your sensor in two, and connect one part to the Arduino Gnd. The additional ground plane is required in detail with battery operation. For testing you can touch the Arduino Gnd with one hand, then approach the sensor with your other hand.

i already try it sir but its result same problem the value not stable when touched. I already try it with ground with one hand and the other hand touch sensor .

  • In the pic, The long foil is connected to ground (the between foil).

And now i use supply from battery 12V (accu) and with stepdown to 6.2 volt for supply arduino & servo. Thank you sir

atleast i could move servo when the value become high and go otherwise when low

Yes you could do that if that fits your undisclosed purpose.

An Update..
when i connect to my laptop (without adapter) to look at serial monitor. The value seem stable (high when touched and low when untouched).

but all i need is this sensor run from battery (VIN)

You have been told what to do.

DrDiettrich:
You have been told what to do.

srry sir but i dont get it.

Because i already try ur sugestions but the problem not solved.

when i try touch GND and then touch sensor, the sensor can read and the value became low (just like without any touch)

Don't touch the sensor, only approach it.

DrDiettrich:
Don't touch the sensor, only approach it.

Oww i try connecting arduino ground pin with a bigger steel and i must using shoes when touch it and its work.

And yes it working too when i only approach it with ground in another hand, thank very much you sirr :smiley:

Hope another person will found this solution too ....