Simple Capacitance Meter
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
- 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.
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)
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]
[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
- 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
- Set Cstray = 0.0; in the header
- Set C1= 10000; in the header
- Compile and upload the code to your Arduino.
- 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
- Change C1 in the header to read 10000*150/160
- Recompile and upload the code to your Arduino.
- C2 should now read 150nF.
- 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
Ekstriem 1 year ago
lingib 1 year ago
To add a display just borrow the code from my Instructable https://www.instructables.com/Multi-task-Your-Ardu...
The necessary code lines are 27,32,147,202..206
HectorR25 1 year ago
lingib 1 year ago
DocNeutron 1 year ago
Presumably this meter could be used to test capacitors in circuits (i.e., for diagnostic purposes). Have you tried that?
lingib 1 year ago
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.
DocNeutron 1 year ago
jon_bondy 1 year ago
lingib 1 year ago
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
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.
jon_bondy 1 year ago
lingib 1 year ago
I have amended Step 2 to read
Step 2
brayden-polaczek 1 year ago
lingib 1 year ago
Palingenesis 1 year ago
lingib 1 year ago
The circuit is extremely useful.
The attached photos show an angle encoder that uses this prionciple.
Am in the process of writing it up
perfo 1 year ago
lingib 1 year ago
Thank you for commenting :)