Capacitive Sensors Troubleshooting - Poor Data Quality


I’m designing capacitive sensors, and I’m trying to measure the capacitance using an Arduino Mega 2560. I’m having an issue with my capacitance measurement data quality, such that I am seeing 3 signals when I am only measuring 1 capacitor’s capacitance.

The capacitances are very small, on the scale of pF, and the method of how I measure the capacitance is by charging the bottom electrode/plate, then measuring the top/sensing electrode’s voltage, and then discharging the capacitor by shutting off the +5 V power supply sent to the bottom electrode. The measured voltage is compared to the parasitic capacitance and a calibration constant, and this is used to calculate the capacitance. I attached a schematic and picture of my setup.

I conducted a pure shear test on my sensor, such that I started recording the capacitance, applied a shear force over time, and removed the shear load. The idea is that when I plot the capacitance over time, I will get a V-shaped plot. **The problem is, my raw data looks like I am measuring 3-signals instead of 1-capacitance signal. ** I am not sure why it is doing this. There seems to be no pattern to the 3 signal plot, it seems to randomly fluctuate between being too high or low. I attached pictures of my data - one of them is when I only plot the middle signal values.

I was thinking maybe the internal clock of the Arduino isn’t fast enough and the slight delays might affect the charge applied to the bottom electrode. That slight charge difference might cause a slight difference in V applied to the bottom electrode. (i.e. 4.99 V instead of 5 V), and that would change the capacitance that is calculated. I attached a pictures of my data.

How do I remove the noise in my raw data? I was looking into doing a Butterworth and Low Pass filter, or using a median filter, but ideally, I want to remove that noise altogether or minimize it such that when I measure one capacitor, I see one capacitance signal recorded instead of 3. I tried doing this with a very large capacitor (1 mF and 1 uF) and got similar results, multiple capacitance signals read for 1 signal with no shear force applied, just a physical capacitor connected to the Arduino - pictures attached.

Is there a better setup I should use to measure capacitance? Should I use a different type of microcontroller? I attached the Arduino code if that helps. Please explain this on a simple level/with detail because I’m new to using Arduino’s and electrical engineering principles.

*** One thing I forgot to mention, I am sampling the sensor data at 50 Hz from the Arduino. So instead of using “while millis() % 100” I am using “while millis() % 20” ***

Thank you!

Capacitance_Meter.ino (1.19 KB)

Was this circuit your own design?
Try disabling the standard Arduino millisecond interrupt otherwise it will mess up the critical timing.

The artifacts may just be due to the way the ADC works. The conversion time is about 110 micro seconds during which it has to figure out which of the 1024 levels match the input voltage.

Another random thought, put a 10x compensated scope probe on the Arduino ADC input to see if the signal is bouncing around due to transmission line effects. Try adding resistance to the Arduino digital output to limit the slew rate. This will also make the measurement timing less critical.

Normally for these sort of measurement you would use an RC oscillator. You either count the number of cycles in a set time period or divide the frequency down to something more Arduino friendly and measure that.

Hi mikb55,

No, I found an example online of somebody measuring capacitance on the scale of picofarads, and I followed that.

What do you mean by putting a 10X compensated scope probe on the Arduino ADC input? I'm going to measure the time constant of my sensor tomorrow to see if the Arduino internal clock is fast enough to take the measurements. I'm still confused on how to find the sampling rate of the Arduino. I think it would just be 1/100 microseconds because I read that "analogRead" takes 100 microseconds to take a measurement.

Can you explain that you mean by the RC Oscillator and dividing the frequency down?


A bit of interesting reading here

Essentially the time at which the ADC sample and hold circuit operates is either 3 or 5 microseconds after the ADC conversion has been initiated.

If you are trying to measure a signal with a fast rise time, then you will see two different voltages depending on whereabouts on the rising slope the readings are taken.

A capacitance to voltage chip such as the Analog Micro CAV444 avoids this problem.

Alternatively the 4060B RC oscillator/counter divider chip is readily available. Minimum capacitance for stability is 50 pF. You'll have to do the experiment to see if it gives the sub pF resolution you require. Pick a divider output that gives a frequency of about 100 Hz and use one of the Arduino frequency measurement libraries to get the frequency.