Strange behavior of Capacitive sensor under differing power supplies

The Project:
A while ago I made myself fancy little light-up to-do list whiteboard with LEDs and capacitive sensors and an Arduino Nano Every as the brain of the whole operation. Since I wanted to actually understand what my program was doing, I didn't use the capacitive sensor library, and programed the capacitive sensing myself. The jist of the device is that for each sensor, a connected IO pin is set high, and then the time is measured until another pin, connected to the first through a resistor of a value I have forgotten, reads high. When the sensor is not being touched this number is quite low, and it jumps considerably when touched. When that number goes above a predetermined threshold, a variable in an array is set to 1. After every sensor has been scanned in this way, the array is checked to see if any of it's variables have changed, and if they have, the corresponding LED is lit, and a little tune is played. Delightful little device that is a much better motivator than just marking a checkmark or erasing a little dry erase marker.

The Problem:
The capacitive sensors behave differently when the board is powered differently. I had initially planned on powering the device with a 9V battery, but when I connected said battery the sensors read different values than when running on USB power. I also discovered that these values differed yet again if both battery and USB power were connected. Nevertheless, I managed to set the threshold through trial and error to a value that worked well enough on the power of a 9V battery, but after a week or so of use the battery died, and I did not want to be burning through batteries that fast, so I decided I would connect it to a more stable power source. A few months later, I finally actually did connect the board to a 9V switching AC-DC adaptor I had laying around (intended for use with guitar effects pedals), and have now encountered an issue where after turning it on under external power some of the sensors seem to trigger at random and the rest will not trigger at all. Most frustrating is that the issue disappears as soon as I connect it to USB, so using the serial monitor to try and trouble-shoot what is actually happening is impossible unless I find a way to bypass the USB power supply. I tried adjusting the program to set the threshold at startup based on the values it reads in the first 4 loops checking the sensors, but that change had no effect, aside from making it take longer for the sensors to start triggering randomly.

So it seems there is something about that power supply that is causing the project to behave erratically, but that something is of little to no effect when also connected to USB power. I do not know what, and I don't really have any guesses. Would a good ole transformer power supply be better? Because I've got one of those lying around too...

Show us a schematic, including the power supply filtering.

Connect the GND of your device to ground (or earth), then check again with different power sources.
Or plug the USB half-way in, so only the external shielding is connected.

The hint here being that whether or not the device has a ground connection (any mains supply automatically becomes a ground connection in capacitive terms, but will differ depending on whether it is double-insulated or the ground is connected directly to the output); affects the capacitance of the whole series circuit including the device to ground, ground to your body and your body to the touch pad. :face_with_raised_eyebrow:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.