Capacitive Sensor bouncing everywhere!!

Hello! So I have tried everything and have been stumped for weeks on this! So I have attached pictures to this forum but basically I have three breadboards, one with a mini arduino pro connected to a capactitive sensor with 3, 1 MegaOhm resistors on a breadboard. I have a ground and the reading port connected to a large poster board with copper tape. The goal for this project is when the user touchers a certain area where the copper tape is, and a sound will play on release of the finger.

I dont know if this is a grounding issue but there will be low numbers that read on the serial monitor (Example: 34, 100, 90) then it will jump into the thousands and back down again so I can never get a steady area of numbers to work with so I can activate the sound on a certain number. I am stumped on this and cannot figure it out, I have tried everything. Attached are pictures of my setup

Also when looking at the pictures: The yellow wire attached to the cardboard is ground and the other wire is the capacitive sensor wire to the arduino.

showforum.jpg

Hi,
OPs pictures.
showforum.jpg


As you are dealing with capacitance, the capacitance between the leads will also have an effect on your readings.
Can you please post your code, using code tags?
Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Thanks.. Tom.. :slight_smile:

How is the Arduino powered?

If you use the Capacitive Sensing Library or the same process (but we can't tell because the lack of code) you need a connection to (protective) earth.

PS It's getting pretty hard to pick a more terrible surface for electronica than you did....

Is the users finger touching BOTH pieces of copper at the SAME time?
Post a photo of the user's finger touching the tape

Capacitive sensors are extremely sensitive to pick-up, so you must provide a ground behind them and
you must keep the layout compact and free from long antenna wires - otherwise you've just created
a mains-interference sensor.

This is a testing demo, so right now it is being tested on from usb on my computer which is on the floor here is the following code:

#include <CapacitiveSensor.h>
#include <SoftwareSerial.h>
#include <DFPlayer_Mini_Mp3.h>

CapacitiveSensor work = CapacitiveSensor(3, 6);       // 10 megohm resistor between pins 4 & 2, pin 2 is sensor pin, add wire, foil
SoftwareSerial mySerial(10, 11); // RX, TX

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

  mySerial.begin (9600);
  mp3_set_serial (mySerial);  //set softwareSerial for DFPlayer-mini mp3 module 
  mp3_set_volume (30);        // Set volume for MP3 player
}

void loop()
{
  long start = millis();
  long total1 =  work.capacitiveSensor(30);

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

  Serial.println(total1);                  // print sensor output 1
  delay(80);         // arbitrary delay to limit data to serial port

if( total1 > 200) {
       Serial.println("on, song should play--------------------");
      mp3_play (1);
      delay(600);
}
     else {
      // if the current state is LOW then the button
      // wend from on to off:
      Serial.println("off");
    }
    // Delay a little bit to avoid bouncing
   // delay(2000);
  }

Is there a better way of doing this or should I say a more reliable way? Like I said the main goal here is when the user touches a picture it would play a sound which the conduction will be behind the picture.

Two thing about the hardware

  • Get the wires short
  • Is that computer by any means a laptop?

It's probably indeed a grounding problem, which is very common for these sensors.
Attaching a laptop will often provide a good enough ground, but not always.
Attach it via USB to a desktop computer that's powered from a grounded outlet (not a given with European or US two-prong plugs) and you should be fine.