# Arduino Capacitance Meter Range 1pF To 4700uF

In this project, I will show you Arduino based capacitance meter which can measure specific values of capacitors. A capacitor is an electrical component that stores electric charge and this capacity of the capacitor to store the electric charge is known as its capacitance. With the assistance of a capacitance meter, we can measure the rate of the charge stored in the capacitor, we can get the capacitance of the capacitor.

Basic Digital Multimeters can’t measure the capacitance and so as to discover the capacitance, you either need to go for a progressed, costly digital multimeters or locate a devoted capacitance module.

The committed capacitance meters frequently accompany a wide scope of estimations of various boundaries like capacitance, inductance, resistance, hFE of a transistor, and so on.

In this project, we will attempt to build a simple Arduino based capacitance meter for two distinct scopes of capacitances. One circuit will be utilized to measure capacitance in the scope of 1µF to 4700µF. The other circuit will be utilized to measure lower capacitance for example in the scope of 20pF to 1000nF.

Note In the event that you need to measure the capacitance from an old circuit or board, be cautious as a capacitor in working condition may store charge regardless of whether the supply is removed. Release the capacitor appropriately before contacting it.

Content

## Components Required

• Arduino
• 16 x 2 LCD Display
• 10 KΩ Resistor
• 220 Ω Resistor
• Connecting wires
• 5V Power supply

### LCD Display to Arduino Nano Setup Connection

• Connect LCD pins 1, 3, 5,16 to the GND pin of Arduino Nano
• Connect LCD pin 4 to the pin D7 of Arduino Nano
• Connect LCD pin 6 to pin D6 of Arduino Nano
• Connect LCD pin 11 to pin D5 of Arduino Nano
• Connect LCD pin 12 to pin D4 of Arduino Nano
• Connect LCD pin 13 to pin D3 of Arduino Nano
• Connect LCD pin 14 to pin D2 of Arduino Nano
• Connect LCD pins 2, 15 to the VCC(+5 V) pin of Arduino Nano

## Working Principle of Capacitance Meter (1uF to 4700uF)

So as to measure the capacitance in the scope of 1 µF to 4700 µF, we need to utilize the above circuit. Before clarifying the working of the project, we will initially observe the principle behind this technique for capacitance measurement.

The principle behind this capacitance meter lies in one of the essential properties of the capacitor: The Time Constant. Time Constant (τ) is characterized as the time taken to charge a capacitor (C) through a resistor (R) to arrive at 63.2 % of the most extreme supply voltage.

On the other hand, the Time Constant (τ) of a capacitor can also be characterized as the time taken by a fully charged capacitor C to discharge to 36.8 % of its extreme voltage through a resistor R.

Smaller capacitors will have less time constant as they set aside less time to charge. Correspondingly, higher capacitors will have higher time constants.

Time Constant τ = R x C (τ = RC)

Here, τ is the time constant of the capacitor in second (s), C is the capacitance of the capacitor in farads (F) and R is the resistance of the resistor in ohms (Ω).

The above circuit and diagram will show you the time constant curvature for a capacitor C, charging to supply voltage V through a resistor R.

We utilize a similar idea in our Arduino based Capacitance Meter. we will charge an unknown capacitor through a known resistance utilizing Arduino and compute the time that it takes to arrive at 63.2 % of the supply voltage (3.1V roughly). In view of the time, I can compute the capacitance from the formula-

C=τ/R

We will utilize a 10 KΩ resistor to charge the capacitor and a 220 Ω resistor to discharge. The charging and discharging pins of the Arduino are pin 8 and pin 9 individually. The voltage over the capacitor is estimated utilizing the analog input pin A0.

At first, we will discharge the capacitor using digital pin 9 to ensure that the capacitor has no charge. we will at that point start the clock and charge the capacitor using the charging pin 8.

Presently, we need to screen the voltage over the capacitor at the analog pin and once it arrives at 63.2% of 5V (roughly 648 from the analog pin), we need to stop the clock and figure out the capacitance.

This circuit is reasonable for nearly higher capacitance as we can plainly measure the time constant. For smaller capacitance, this circuit probably won’t be appropriate.

## Arduino Code

``````// Electro Gadget - circuitdiagrams.in
#include <LiquidCrystal.h>
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);
int charge = 8;
int discharge = 9;
int analogPin = A0;
unsigned long start_timer=0;
unsigned long stop_timer=0;
unsigned long duration=0;
float voltage=3;
int measure (void);
void setup()
{
Serial.begin(9600);
lcd.begin(16, 2);
lcd.print("1uF to 4700uF");
lcd.setCursor(0,1);
lcd.print("Place Capacitor ");
pinMode(discharge,INPUT);
pinMode(charge,OUTPUT);
digitalWrite(charge,HIGH);
}
void loop()
{
while(measure()>=1010 && measure()<=1030)
{
lcd.setCursor(0,1);
lcd.print("Place Capacitor ");
delay(200);
lcd.setCursor(0,1);
lcd.print("                ");
delay(200);
}
delay(2000);
lcd.setCursor(0,1);
lcd.print("                ");
while(1)
{
pinMode(charge,INPUT);
pinMode(discharge,OUTPUT);
digitalWrite(discharge,LOW);
lcd.setCursor(0,1);
lcd.print("Discharging");
while(voltage>2.0)
{
voltage=measure();
delay(100);
lcd.setCursor(12,1);
lcd.setCursor(14,1);
lcd.print("%");
}
lcd.setCursor(0,1);
lcd.print("                ");
delay(1000);
lcd.setCursor(0,1);
lcd.print("Charging");
lcd.setCursor(13,1);
lcd.print("%");
pinMode(discharge,INPUT);
pinMode(charge,OUTPUT);
digitalWrite(charge,HIGH);
start_timer=micros();
while(measure()<648)
{
lcd.setCursor(9,1);
lcd.print(measure()*(100.0/1023.0),1);
}
stop_timer=micros();
duration=stop_timer-start_timer;
lcd.clear();
// lcd.setCursor(0,1);
// lcd.print("                ");
lcd.setCursor(0,0);
lcd.print("Value = ");
lcd.print("uF");
delay(3000);
while(1)
{
lcd.setCursor(0,1);
lcd.print("Press Reset");
delay(200);
lcd.setCursor(0,1);
lcd.print("                ");
delay(200);
}
}
}
int measure (void)
{
int value;

return value;
}``````

## Components Required

• Arduino
• 16 x 2 LCD Display
• Connecting wires
• 5V Power supply

### LCD Display to Arduino Nano Setup Connection

• Connect LCD pins 1, 3, 5,16 to the GND pin of Arduino Nano
• Connect LCD pin 4 to the pin D7 of Arduino Nano
• Connect LCD pin 6 to pin D6 of Arduino Nano
• Connect LCD pin 11 to pin D5 of Arduino Nano
• Connect LCD pin 12 to pin D4 of Arduino Nano
• Connect LCD pin 13 to pin D3 of Arduino Nano
• Connect LCD pin 14 to pin D2 of Arduino Nano
• Connect LCD pins 2, 15 to the VCC(+5 V) pin of Arduino Nano

## Working Principle of Capacitance Meter (20pF to 1000nF)

For estimating smaller capacitances, we will utilize an alternate idea. For this, we have to study the inner structure of the ATmega328P chip.

All the I/O ports in the ATmega328P microcontroller have an internal pull-up resistance and an internal capacitance associated between the pin and ground.

Here, Ct is the capacitor under test, and Ci is the internal capacitance of the Arduino. We need not stress over the internal capacitor and its range can be between 20 pF to 30 pF. The unknown capacitor is associated with analog pin A2 and pin A0. Here, A2 goes about as the charging pin, and A0 goes about as the discharging pin.

At first, we will charge the unknown capacitor by setting A2 as HIGH and measure the voltage at A0 from the following equation.

Voltage V(A0) = (VA2 X Ct)/(Ct+Ci)

Yet, we definitely know the voltage at A0 with the assistance of the analog read function. Subsequently, utilizing that value in the above condition, we can get the unknown capacitance as follows

Ct = (Ci X VA0)/(VA2-VA0)

## Arduino Code

``````//Electro Gadget - circuitdiagrams.in
#include <LiquidCrystal.h>
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);
const int analog_charge = A2;
const int analogPin = A0;
float ck=24.42;
int voltage;
float cu;
void setup()
{
Serial.begin(9600);
lcd.begin(16, 2);
lcd.print(" 20pF  to 1000nF ");
lcd.setCursor(0,1);
lcd.print("Place Capacitor ");
pinMode(analogPin,OUTPUT);
pinMode(analog_charge,OUTPUT);
}
void loop()
{
abc:
pinMode(analogPin,INPUT);
digitalWrite(analog_charge,HIGH);
digitalWrite(analog_charge,LOW);
//analog_charge = 998 || 999 || 1000 || 1001 and ! 1024
pinMode(analogPin,OUTPUT);
if(voltage<1000)
{
cu=((ck*voltage)/(1024.0-voltage));
if(cu>20.0)
{
lcd.setCursor(0,1);
lcd.print("                ");
lcd.setCursor(0,1);
lcd.print(cu,2);
lcd.print("pF");
}
else
{
lcd.setCursor(0,1);
lcd.print("Place Capacitor ");
delay(200);
lcd.setCursor(0,1);
lcd.print("                ");
delay(200);
goto abc;
}
}
else
{
voltage=0;
pinMode(analogPin,OUTPUT);
delay(1);
pinMode(analog_charge,INPUT_PULLUP);
unsigned long start_time = micros();
unsigned long final_time=0;
while((voltage < 1) && (final_time < 400000L))
{
unsigned long stop_time = micros();
final_time = stop_time > start_time ? stop_time - start_time : start_time - stop_time;
}
pinMode(analog_charge, INPUT);
digitalWrite(analogPin, HIGH);
int delay_T = (int)(final_time / 1000L) * 5;
delay(delay_T);
pinMode(analog_charge, OUTPUT);
digitalWrite(analog_charge, LOW);
digitalWrite(analogPin, LOW);
cu = -(float)final_time / 34.8 ;
cu /= log(1.0 - (float)voltage / (float)1023);
if(cu < 1000.0)
{
lcd.setCursor(0,1);
lcd.print("                ");
lcd.setCursor(0,1);
lcd.print(cu,2);
lcd.print("nF");
}
else
{
lcd.setCursor(0,1);
lcd.print("                ");
lcd.setCursor(0,1);
lcd.print("Error");
}
}
delay(1000);
}``````