CapacitiveSensor library returning only 0 values

Hi,

I have an Arduino Leonardo and I'd like to use the CapacitiveSensor library.
I have everything set up correctly but the sensor reading returns 0 all the time, it doesn't react to touching the sensor cable.

Can tou tell me what the issue could possibly be? Any help would be appreciated.

My configuration: BLACK - sendPin (8 ), RED - receivePin (7), WHITE - sensorPin (I touch this one).
I use a 1 MegaOhm resistor.

CapacitiveSensor   cs_8_7 = CapacitiveSensor(8,7);

...

long start = millis();
    long total1 =  cs_8_7.capacitiveSensor(15);

    Serial.print(millis() - start);        // check on performance in milliseconds
    Serial.print("\t");                    // tab character for debug windown spacing

    Serial.println(total1);                  // print sensor output 1
 

    delay(10);                             // arbitrary delay to limit data to serial port

What I get:

0                                  0
1                                   0
0                                  0
0                                  0
0                                  0
0                                  0
1                                   0
0                                  0
0                                  0

DSC_1135[1].JPG

Hi, can you post the complete sketch, so we can see if the setup and includes are okay.

Have yu read here?

http://playground.arduino.cc/Main/CapacitiveSensor?from=Main.CapSense

You have a 220 Ohm resistor between send and receive pins, they quote at least 100K Ohms.

Tom… :slight_smile:

Here is the complete Sketch. It was derived from the example sketch of the library.

#include <CapacitiveSensor.h>

/*
 * CapitiveSense Library Demo Sketch
 * Paul Badger 2008
 * Uses a high value resistor e.g. 10M between send pin and receive pin
 * Resistor effects sensitivity, experiment with values, 50K - 50M. Larger resistor values yield larger sensor values.
 * Receive pin is the sensor pin - try different amounts of foil/metal on this pin
 */


CapacitiveSensor   cs_8_7 = CapacitiveSensor(8,7);        // 10M resistor between pins 8 & 7, pin 7 is sensor pin, add a wire and or foil if desired

void setup()                    
{
   //cs_8_7.set_CS_AutocaL_Millis(0xFFFFFFFF);     // turn off autocalibrate on channel 1 - just as an example
   Serial.begin(9600);
}

void loop()                    
{
    long start = millis();
    long total1 =  cs_8_7.capacitiveSensor(15);

    Serial.print(millis() - start);        // check on performance in milliseconds
    Serial.print("\t");                    // tab character for debug windown spacing

    Serial.println(total1);                  // print sensor output 1
 

    delay(10);                             // arbitrary delay to limit data to serial port 
}