Capacitance Measurement using Arduino

Definition

Capacitance is defined as the ability of a body to store an electric charge. The SI unit of capacitance is the farad (symbol: F), named after the English physicist Michael Faraday. A 1 farad capacitor, when charged with 1 coulomb of electrical charge, has a potential difference of 1 volt between its plates.

Capacitance Measurement

                Each Arduino capacitance meter relies on the same basic property of capacitors- the time constant. The time constant of a capacitor is defined as the time it takes for the voltage across the capacitor to reach 63.2% of its voltage when fully charged. Larger capacitors take longer to charge, and therefore have larger time constants. An Arduino can measure capacitance because the time a capacitor takes to charge is directly related to its capacitance by the equation:

TC = R x C
TC is the time constant of the capacitor (in seconds).
R is the resistance of the circuit (in Ohms).
C is the capacitance of the capacitor (in Farads).

Algorithm for capacitance measurement code

  1. Set discharge pin to INPUT (so it can’t discharge the capacitor)
  2. Set charge pin to OUTPUT and make it HIGH
  3. Record the start time with millis()
  4. Check the voltage repeatedly in a loop until it gets to 63.2% of total voltage.
  5. After the cap is charged, subtract the current time from the start time to find out how long the capacitor took to charge.
  6. Divide the Time in seconds by the charging Resistance in ohms to find the Capacitance.
  7. Report the value with print on Serial monitor.
  8. Discharge the capacitor. To do this:
  9. Set the charge pin to Input
  10. Set the discharge pin to OUTPUT and make it LOW
  11. Read the voltage to make sure the capacitor is fully discharged
  12. Loop and do it again

Capacitance Measurement Circuit

Capacitance Measurement using RC timing
Capacitance Measurement using RC timing
Arduino Capacitance Measurement Circuit
Capacitance Measurement Circuit

Arduino Code for Capacitance Measurement

Result of Capacitance Measurement

                The code will wait on this line If there is no capacitance Connected

“ while(analogRead(analogPin) < 648)    // 647 is 63.2% of 1023, which corresponds to full-scale voltage”

Connect the capacitor between test terminals and observe the serial monitor will show the result. If no capacitance is connected serial terminal will not show anything.

Result of capacitance measurement
Result of capacitance measurement

Leave a Reply

Your email address will not be published. Required fields are marked *