Introduction: Capacitance Meter

About: 55+ years in electronics, computers, and teaching ... now retired.

This instructable describes how to measure the value of an unknown capacitor using an Arduino Uno R3 and a resistor.

The circuit is unusual in that it uses the Arduino interrupt to determine the capacitance.

A wide range of capacitance values, from zero picofarads (pF) to microfarads (uF), may be measured using a single resistor.

To reduce the time to measure large capacitors the meter has two capacitance ranges:

  • below 1uF
  • above 1uF

Construction is simple.

Accuracy is excellent.

Excluding the Arduino, the cost of this project is less than $10.00.

Images

  • The cover photo shows how the meter is constructed.
  • The video demonstrates the meter in operation.


Supplies

 The following parts were obtained from https://www.aliexpress.com/

  • 1 only Arduino UNO R3 with USB cable

The following parts were obtained locally:

  • 1 only 10M ohm resistor
  • 1 only 10k ohm resistor
  • 1 only 270 ohm resistor
  • 1 only switch
  • 2 only test clips
  • Hookup wire
  • Arduino header pins for mounting the components

Excluding the Arduino, the cost of this project is less than $10.00

Step 1: Circuit

Operation

The capacitor under test is connected between interrupt pin2 and ground.

The 10M ohm resistor is for capacitance values less than 1 microfarad. When the switch is open the capacitor is charged via the 10M ohm resistor.

The 10K ohm resistor is for capacitance values greater than 1 microfarad. When the switch is closed the capacitor is charged via the 10K ohm resistor.

At some point in time the voltage across the capacitor will trigger the Arduino interrupt.

The capacitance value is directly proportional to a fixed fraction of the elapsed charge time. The capacitance formula is derived in the Theory section which follows.

The 270 ohm resistor limits the peak discharge current to a safe value of 18.5 millamps


Construction

Photo 2 shows how the components are wired to a pair of Arduino header-strips.

  • One end of each resistor is connected to Ardino pin 2.
  • The other end of the 10M ohm resistor is connected to Arduino pin D8.
  • The other end of the 10K ohm resistor is connected to Arduino pin D9.
  • The other end of the 270 ohm resistor is connected to Arduino pin D10.
  • The switch is connected between Arduino pin D11 and ground.
  • The test leads are connect to Arduino pins D2 and ground.

Step 2: Theory

When a capacitor is charged via a series resistance the instantaneous voltage across the capacitor may be found using the following formula [1]

v = Vin*(1-e^(-t/CR)) …………………………………………. (1)

where:

  • v = instantaneous capacitor voltage
  • Vin=applied voltage
  • e=2.7182818284590452353602874713527
  • t=time in seconds
  • C= capacitance in farads
  • R=series resistance in ohms


When the exponent t/CR = 1 the capacitor voltage is:

v = Vin*(1 – e^(-1))

v = Vin*(1 – 0.368)

v = 0.632 * Vin


Rearranging t/CR=1 we get

C=t/R ………………………………………………………….... (2)


Polling Method

Equation (2) can be used to calculate the value of an unknown capacitor if we continuously sample (poll) the capacitor voltage with an ADC (analog to digital convertor) and note how long it takes for the capacitor voltage to reach 63.2% of the applied voltage.

For large value capacitors this method is reasonably accurate, as the polling loop-time is a small fraction of the capacitor charging-time which means the error is small.

But for small value capacitors, which charge quickly, the fixed ADC loop-time becomes a large fraction of the capacitor charging time which means the error can be large.

The following method eliminates polling which means that low value capacitors can be measured accurately.


Interrupt Method

Instead of polling, I use the Arduino interrupt to detect when the capacitor becomes fully charged.

In theory a capacitor may be regarded as fully charged when t/CR = 5

v = Vin*(1 – e^(-5))

v = Vin*(1 – 0.007)

v = 0.997 * Vin


Rearranging the exponent we get

C = t/(R*5) …………………………………………………...….. (3)

where

  • C = capacitance in farads
  • t = elapsed charge time in seconds
  • R= series resistance in ohms


In practice the Arduino interrupt will trigger at a lower voltage in which case equation (3) becomes:

C = t/(R*Constant) ……………………………………………… (4)

where

  • C = capacitance in farads
  • t = elapsed charge time in seconds
  • R= series resistance in ohms
  • Constant between 0..5 (determined experimentally)


A typical value for the Constant is around 0.8.


Examining equation (4) we see that the capacitance C is directly proportional to a fixed fraction of the elapsed time.

To calibrate we simply connect a known value of capacitance between pin 2 and ground and adjust the numeric Constant value for a correct capacitance reading.

Since the interrupt trigger level and series resistance don’t change, the Constant is valid for all capacitor measurements.

This allows capacitor values from zero picofarads (pF) to several hundred microfarads (uF) to be measured using a single resistor.


Observation

When measuring small capacitance values, a large series resistance improves the resolution by extending the trigger time.

Unfortunately, this also extends the time to measure large capacitors. This time interval can be reduced by using a lower value resistor. In my circuit this is achieved by means of a switch connected between Arduino pin 11 and ground.


Reference

[1]

https://mechatrofice.com/circuits/charging-capacitor-derivation

Step 3: Software Installation

Method:

  •  Download the attached file “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 "capacitance_meter" (without the quotes)
  • Compile and upload the sketch to your Arduino.

Step 4: Calibration & Measurements

Low value capacitors

Step 1

  • Open the switch

Step 2

Zero out the system time

  • Change code line 95 to read: Time_taken = Stop_time – Start_time;
  • Upload the code change to your Arduino
  • Disconnect the capacitor
  • Open your Serial Monitor at 115200 bauds
  • Note the Time_taken value shown in microseconds … let’s assume it’s 320us [1]
  • Change code line 95 to read: Time_taken = Stop_time – Start_time – 320;
  • Upload the code change to your Arduino
  • The Time_taken value should now show 0us with the capacitor disconnected

Step 3

Adjust the Constant

  • Connect a 150nF (nanofarad) capacitor between Arduino pin2 and ground. [2]
  • Change the numerical value of Constant_10M in the header section until a reading of 150nF is displayed.
  • Replace the capacitor with one you wish to measure ...the new reading is the value of the chosen capacitor


Large value capacitors

Step 4

  • Close the switch.
  • Repeat steps 2 & 3 but this time change the equation in code line 120 and the value for Constant_10K in the header.


Notes

[1]

The Arduino system timer uses a 32-bit register so a number such as 4294967294 equates to FF FF FF FE in hexadecimal which is -1 decimal in two’s complement arithmetic.

If you see a large number, such as 4294967294, change the code line to read

Time_taken = Stop_time – Start_time + 100;

Upload this new code to your Arduino and note the reading … let’s assume that you see 60us

Subtract this new reading from 100

100-60 = 40

Change the code line to read

Time_taken = Stop_time – Start_time + 40;

Upload this new code to your Arduino … the Time_taken value should now show 0us with the capacitor disconnected.


[2]

The actual capacitance value used for calibrating is not critical providing you know its value.

Step 5: Summary

This instructable describes how to measure the value of an unknown capacitor using an Arduino Uno R3 and a resistor.

The circuit is unusual in that it uses the Arduino interrupt to determine the capacitance.

A wide range of capacitance values, from zero picofarads (pF) to microfarads (uF), may be measured using a single resistor.

To reduce the time to measure large capacitors the meter has two capacitance ranges:

  • below 1uF
  • above 1uF

Construction is simple.

Accuracy is excellent.

Excluding the Arduino, the cost of this project is less than $10.00.

  Click here   to view my other instructables.


Anything Goes Contest

Participated in the
Anything Goes Contest