I'm playing with a wireless sensor device (with atmega, xbee, and Capacitive sensor (simple foil)) that works fine with the lab power supply but as soon as I try it with AA batteries stops working. Wireless communication and atmega seems to work fine, but de Capacitive sensor (I use and arduino CapSense library) dosn´t work. It seems to have something to do with the GROUND from Capacitive sensor I've also tried supplying power directly to the battery box, so no wires seem out of place neither...

Any tipps, recomendations, or saviour tests?? Sorry if I ask a basic concept... I´m newbie...

EDIT: I reformulate ask and attach an image enter image description here



EDIT2: Thanks Ambiorix for explain me the problem on my circuit!

  • \$\begingroup\$ "because when I touch a negative (i´m grounding?¿), the capacitive foil seem works fine..." - what is this supposed to mean? What is a negative and where did you touch it. For your last sentence about the battery box - Do you mean you applied power with a power supply to the box and it worked fine? \$\endgroup\$
    – I. Wolfe
    Jan 28, 2015 at 22:47
  • \$\begingroup\$ That depends on how the sensor work, a capacitive sensor does not require grounding. Does it work if you touch the foil and the circuit ground, i.e. the battery negative? \$\endgroup\$ Jan 28, 2015 at 22:48
  • \$\begingroup\$ Hi, thanks for answers. In case I connect my circuit (whith capacitive foil) directly to my lab power supply, I not need to touch a negative pole from battery... but when I connect a AA baterry, the capacitive not work until I touch a negative pole in my circuit... Sorry I am not explain better, I´m use google translate \$\endgroup\$ Jan 28, 2015 at 22:59
  • 1
    \$\begingroup\$ Diagram or picture would help us understand, the machine translation is not very clear. \$\endgroup\$
    – pjc50
    Jan 28, 2015 at 23:31

2 Answers 2


This CapSense library distinguishes between touch and no touch through the increase/decrease of the time delay caused by the series resistance and capacitance to the earth. This obviously requires the Arduino to be connected to the earth.

If you use a power supply the Arduino is either directly connected to the earth via the mains plug or via the stray capacitances through the PS, which are considerably higher than the sensor's capacitance to the earth. The stray capacitance between the battery and earth is far to low for this to work.


  • Connect the Arduino board to a heating pipe or earth pin of a socket.
  • Make use of capacitive sensing though an oscillator and PLL like proximity sensors do. Is more reliable, but also more complex, requires additional electronics and is not always possible depending on your application.
  • \$\begingroup\$ Wow, thank you very much for your clear explanation. What do you mean by "oscillator and PLL"? ... This is a sensor that should be activated by pressing the foil an animal. Do you think it's possible? Thanks again for your altruism. \$\endgroup\$ Jan 29, 2015 at 9:28
  • 1
    \$\begingroup\$ @xavi: I mean something like this. Or other equivalent circuits or IC. adafruit.com/datasheets/AT42QT1010.pdf This works on different principles that are far more reliable IMO. Obviously you need additional circuitry. \$\endgroup\$
    – Ambiorix
    Jan 29, 2015 at 21:47
  • \$\begingroup\$ Nice!! Thank you very much Ambiorix, I consider to implement that chip on my project. But, I prefer not include another chip on my dessing, ...It is possible to add a ground for my circuit without heating pipe? the problem is I can´t implement a "wire to earth" on my dessing ...I try to connect a big metal plane in negative pole and works, but returns a inestable results.. on last, I need use the capacitive sensor for detect a little animal passing across foil.. ¿you thing with my actual dessing it works? Sorry for abuse you... :( Regards! \$\endgroup\$ Jan 30, 2015 at 9:59
  • 1
    \$\begingroup\$ If the large ground plane doesn't warrant stable operation it's going to be hard. Another option is a coupling type of capacitive sensor, but again this increases complexity. Vintage TV sometimes had such sensors. ecnmag.com/articles/2011/01/…. \$\endgroup\$
    – Ambiorix
    Jan 30, 2015 at 10:37
  • \$\begingroup\$ Understood, I will try to put the ground directly to earth, or perhaps put a chip of these you suggest. Thank you very much again for your wisdom and your time. Greetings! \$\endgroup\$ Jan 30, 2015 at 11:35

I'm a few months late to this thread, but I've run into the same problem that xavi has. Adding a ground (approx. 30cm of copper pipe) helps with some circuit configurations but not the one I want to use.

However, I've found that the circuit can be used as a filter to determine when the capacitance changes. That is, send a square wave through the circuit at a frequency that is either attenuated or passed, and then when the capacitance changes you can detect a difference in the response. I'm doing the following:

  • Set up a pin change interrupt on the receiving pin on CHANGE transitions.
  • Use the Arduino tone() function to send a square wave on the sending pin.
  • Delay for a few milliseconds while counting the transitions on the receiving pin.
  • Turn off the tone and disable the pin change interrupt.

If the frequency is close to the cutoff frequency you can see a dramatic change in the transition counts when the capacitance changes. This works both on mains power and batteries. However, the response of the filter changes, so you have to tune the frequency for each power source and touch object. (I've used a foil plate, a banana, and plant fronds. All work well with high sensitivity.) I'm still working on a calibration routine to perform on power-up.

The circuit I'm using is a little different, because I was trying to detect the discharge rate of the charge. I may try different configurations of the resistor and the capacitor. You can see my circuit and earlier tries at http://ideas-tried.blogspot.com/2015/06/capacitive-sensing-on-battery-power.html.

  • \$\begingroup\$ Thanks Mark! I will try your solution, because I continue getting errors with my capacitive sensor! Can you post a code example plis? Thanks in advance! \$\endgroup\$ Mar 15, 2016 at 17:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.