Simple Capacitance Meter

7.1K7721

Intro: Simple Capacitance Meter

This instructable explains how to measure capacitance values in the range 0pF to 10uF using an Arduino and a 10nF reference capacitor.

The circuit does not use the time constant formula, or measure the elapsed time to charge a capacitor to some predetermined value.

Instead capacitance values are determined by multiplying the reference capacitance by the voltage ratio formed when the unknown capacitance is connected in series with the reference capacitor.

Construction is simple … only three solder connections are required.

Features include

  • Wide range … 0pF - 10uF
  • High accuracy.
  • Fast and stable readings.

Other ranges are possible by changing the reference capacitor.

The estimated cost, excluding the Arduino, is less than $5.00


Images


  • The cover photo shows the prototype capacitance meter attached to a variable capacitor. The reference capacitor is the small brown blob.
  • Photo 2 shows the final version of the capacitance meter.
  • The video demonstrates the capacitance meter reading standard capacitor values.

STEP 1: Circuit Diagram

 The circuit diagram is shown in photo 1.

Construction details are shown in photo 2.


Operation


The series connected capacitors form a voltage divider when A2 is forced HIGH and A0 is forced LOW.

The applied voltage is equivalent to an ADC (analog to digital converter) count of 1023

The voltage across C is equivalent to the ADC reading on pin A1.

The unknown capacitance is equal to the reference capacitance multiplied by the capacitor voltage ratio less any stray capacitance. The stray capacitance is the measurement obtained without capacitor C connected.

The actual capacitance is therefore

  • C = C1*(1023-ADC)/ADC – Cstray ………………………… (1)

Following each measurement, the charge on both capacitors is removed by forcing pins A0, A1, and A2 LOW.

STEP 2: Theory

This step is mathematical and may be skipped


The formula for the calculating the charge on a capacitor is

  • Q = I*T = C*V ……………………………………..… (1)

where

  • Q = charge in coulombs
  • I = current
  • T = time
  • C = capacitance in farads
  • V = voltage across the capacitor


The instantaneous charge on each capacitor will be the same since both capacitors receive the same charging current for the same length of time therefore

  • q1 = q2 …………………………………………......….(2)

where

  • q1 is the charge on C1
  • q2 is the charge on C2


But:

  • q1 = C1*(Vin-Vout) ……………………………….….. (3)
  • q2 = C2*Vout …………………………………………. (4)


where

  • q1 = charge on C1
  • q2 = charge on C2
  • Vin = applied voltage
  • Vout = output voltage across C2


Substituting equations (3) and (4) into equation (2) and rearranging

  • C2 = C1*(Vin – Vout)/Vout ………………………..…. (5)


Assuming Vin is equivalent to an ADC (analog to digital converter) count of 1023, equation (5) becomes

  • C2 = C1*(1023 – ADC)/ADC …………………….….. (6)


where

  • C1 = reference capacitor
  • C = unknown capacitance
  • 1023 = Arduino 5V
  • ADC = Arduino analog to digital converter reading


The value for C2 includes the input capacitance of your Arduino ADC. This capacitance, which is in the order of 29pF, may be ignored when measuring large values of capacitance, but is significant when the capacitor values are small.


The following formula allows for this stray capacitance

  • C2 = C1*(1023 – ADC)/ADC - Cstray ………………………….. (7)



Theoretical Measuring Range


The following calculations use equation (6) and assume C1=10nF

When the ADC count is 1:

C2 = 10000*(1023 -1)/1 pF

= 10 uF [1]


When the ADC count is 512

C2 = 10000*(1023-512)/512 pF

= 10nF

= reference capacitor


When the ADC count is 1022

C2 = 10000*(1023-1022)/1022pF

= 10pF [2]


Notes

[1]

Larger capacitance values require a larger reference capacitor.

[2]

When measuring low value capacitors the accuracy can be improved by using a smaller reference capacitor.

For example if C1 is 1nF then the low value resolution becomes 1pF.

STEP 3: Software Installation

 Method
  • Download the attached file “simple_capacitance_meter.ino”
  • Copy the contents into a new Arduino sketch. (Use a text editor such as Notepad++ ... not a word processor.)
  • Save the sketch as "simple_capacitance_meter" (without the quotes)
  • Compile and upload the sketch to your Arduino.


STEP 4: Calibration

 Step 1
  • Set Cstray = 0.0; in the header
  • Set C1= 10000; in the header
  • Compile and upload the code to your Arduino.


Step 2
  • Connect a 150nF (nanofarad) capacitor between the test probes
  • Open your Serial Monitor at 115200 bauds.
  • Note the reading … let’s assume that the reading is 160nF


Step 3
  • Change C1 in the header to read 10000*150/160
  • Recompile and upload the code to your Arduino.
  • C2 should now read 150nF.


Step 4
  • Disconnect C2
  • Note the reading … let’s assume the reading is 29pF (picofarads)
  • Change Cstray in the header to read Cstray=29;
  • Recompile and upload the code to your Arduino
  • The reading should now read 0pF


Calibration is now complete.

  • The reading should be zero with nothing connected to the probe
  • The reading should be 150nF when you reconnect the 150nF capacitor
  • The reading you get when you connect an unknown capacitor between the probes is the value of the unknown capacitor.

STEP 5: Summary

This instructable explains how to measure capacitance values in the range 0pF to 10uF using an Arduino and a 10nF reference capacitor.

The circuit does not use the time constant formula, or measure the elapsed time to charge a capacitor to some predetermined value.

Instead capacitance values are determined by multiplying the reference capacitance by the voltage ratio formed when the unknown capacitance is connected in series with the reference capacitor.

Construction is simple … only three solder connections are required.

Features include

  • Wide range … 0pF - 10uF
  • High accuracy.
  • Fast and stable readings.

Other ranges are possible by changing the reference capacitor.

The estimated cost, excluding the Arduino, is less than $5.00

  Click here   to view my other instructables.

17 Comments

This is so simple and so nice. I am looking for this idea for years because the angle is absolute. Now I can readout the Angle of Attack of the incomming airstream. Please help me further with a display read out with OLED or Matrix?

Great instructable….practical and straightforward.
Presumably this meter could be used to test capacitors in circuits (i.e., for diagnostic purposes). Have you tried that?
Thank you for commenting :)

I've not tried measuring in-circuit capacitance but would be surprised if it would work as the capacitance under test must be fully discharged between readings.

In theory the test probe connected to pin A0 could be connected to GND (ground) ... but in practice the slight difference between a logic LOW on pin A0 and GND leaves a residual charge on the capacitor under test.

Since this circuit isn't using the time constant formula any residual charge creates a significant error.
You say "note the reading", but I do not see a display. What do you mean by "note the reading"?
Thank you for your interest in my project :)

By "Note the reading" I mean record or write-down the reading you get when you connect a 150nF capacitor between the test probes. This assumes that you have built the capacitance meter and have your Serial Monitor running.

Step 2
  • Connect a 150nF (nanofarad) capacitor between the test probes
  • Note the reading … let’s assume that the reading is 160nF

In Step 2 we are expecting a reading of 150nF but instead get a reading of 160nF which is too high ... probably due to stray capacitance across the reference capacitor or possibly the reference capacitor isn't perfect.

To correct this error we need to make the reading smaller. To do this we multiply each subsequent reading by150/160 using the method outlined in Step 3.
You never mentioned the Serial Monitor at all, that I can see. Perhaps you could make minor edits to clarify what you intended.
Thank you for your suggestion :)
I have amended Step 2 to read
Step 2
  • Connect a 150nF (nanofarad) capacitor between the test probes
  • Open your Serial Monitor at 115200 bauds.
  • Note the reading … let’s assume that the reading is 160nF
Fantastic, this will be a nice tool with a display added.
Thank you for commenting :)
The circuit is extremely useful.
The attached photos show an angle encoder that uses this prionciple.
Am in the process of writing it up
Another great, detailed, instructable Lingib. Maybe this would work on an MCU board and thus be $10 for the whole thing which is pretty good for a capacitance meter of this accuracy and ease of use.
That's an interesting thought ...
Thank you for commenting :)