Need help with a simple touch sensing circuit

I’m trying to use this captouch library https://github.com/lbt/captouch to make the D7 LED turn on and off with touch.

The circuit is just one 10M resistor between D3 and D6. I’m testing by touching the side of the resistor.

I’m using Arduino’s Serial Monitor to see what it’s reading. The values are all over the place and the events it’s reporting are totally inaccurate.

Is there a problem with the library I’m using? I’m not sure where to go from here…

#include <captouch.h>
#include "application.h"


//captouch
#define pTouch	D3
#define pSense	D6
#define CAPTOUCH_DEBUG true


CapTouch Touch(pTouch, pSense);

void setup(){
    Serial.begin(9600);
        Touch.setup();
        pinMode(D7, OUTPUT); 

}


void loop(){
        delay(100);
        CapTouch::Event touchEvent = Touch.getEvent();


    if (touchEvent == CapTouch::TouchEvent) {
                	digitalWrite(D7, HIGH); // LED on

    } else if (touchEvent == CapTouch::ReleaseEvent) {
                	digitalWrite(D7, LOW);  // LED off

    }
    
}

That's not enought.
Here you can find a schematic to show how it should look like.
http://jvs.me/spark-core/touch-sensing-on-the-spark-core/

The search feature of this forum may have helped locate that link
This is where I found it via the search term: captouch.h

I would suggest you put a capacitive touch controller on the pin if you want to make your life easy. The controllers run calibration and will provide a clean output. You can pick up a single touch pad and controller on a little PCB for $1 or less.

2 Likes

Thanks for the help! I think going the easy route and getting a capacitive touch breakout board is the right solution for me.

1 Like