Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe

Capacitance Measurement using Arduino

By Ajish Alfred February 8, 2019

Introduction

This is a project based on Arduino board which can measure the unknown capacitance value. When the capacitor whose value needs to be measured is plugged into the breadboard of the Capacitance meter, the 16*2 LCD displays the capacitance value. The project uses an Arduino pro mini boardwhose ADC feature is used along with the concept of RC charging circuit to develop this Capacitance meter.

Fig. 1: Prototype of Arduino based Capacitance Meter

Description

The entire project can be divided into three basic blocks;

1)      Capacitance Sensor Unit

2)      Processor Unit

3)      Display Unit

Fig. 2: Block Diagram of Arduino based Capacitance Meter

The Capacitor Sensor Unit allows an input capacitor to charge or discharge through it. The voltage across the capacitor while it charges or discharges appears as the output of the Sensor Unit.

The Processor Unit can take input voltage in the range of 0 to 5V.This unit can make the Sensor unit to charge or discharge the capacitor. This unit takes the Sensor Unit’s output as input voltage and uses the ADC to read that voltage. An Algorithm is then applied to calculate the capacitance value. The unit then sends a 4bit data to the Display Unit to display the capacitance value.

The Display Unit takes the 4bit data from the Processor Unit and produces a 16*2 display for the value of capacitance.

1)      CapacitanceSensor

The Capacitance sensor in this project is an RC discharging circuit in which the unknown capacitor is discharged through a known resistor. An RC discharging circuit is a circuit in which a capacitor and a resistor are connected in parallel. In a RC discharging circuit the time taken for the capacitor to discharge through the resistor to half the voltage before starts discharging is dependent on the values of resistance and capacitance.

 

Fig. 3: Circuit Diagram of Capacitance Sensor

Consider the capacitor ‘C’ in an RC circuit charges and discharges through a resistor ‘Rc’, and while discharging let ‘T’ be the time taken for the capacitor to drop the voltage across it to half the voltage before it starts discharging, then the capacitance ‘C’ can be calculated using the following equation;

C = T / (0.693 * Rc)

The capacitor in this project is allowed to charge for a while, measure the voltage across it and then allows it to discharge through known resistor ‘Rc’. The time taken ‘T’ till the voltage across it drops to half the voltage is noted and from that we can calculate the capacitance value.

 

Selecting the value of Rc;

Let us assume the maximum value of capacitance C = 100 uF, that can be measured with a discharge time of T = 10 s, then the discharge resistance Rc can be calculated as,

Rc = T / (0.693 * C)

Rc = 1 / (0.693 * 100 uF) = 144300 ohms, Let us select 100K standard resistor

1)      Processor Unit

The processor unit in this project is the Arduino board and it uses the ADC module to read the output voltage from the Sensor Unit. The processor unit first charges the capacitor in the sensor unit by applying 5V for a while and then suddenly removes that charging voltage. From that moment the capacitor starts discharging through the resistor Rc. The algorithm in the Processor unit continuously read the voltage Vc from the Sensor Unit using ADC, and takes the difference in time ‘T’ from the moment it starts discharging till the Vc becomes half the voltage that was present across the capacitor before it starts discharging.

In the Arduino board we are using an 8 channel, 10 bit ADC with the reference voltage pin connected to 5 V. The ADC reads the voltage Vc and generates an equivalent value ‘ValueADC‘at the ADC register. From this value the algorithm calculates[H1]  the voltages Vc, measures the discharge time ‘T’ and then the Capacitance.

Once the value of discharge time ‘T’is obtained the value of Capacitance is calculated using the known values of Rc = 100K with the help of equation;

C = T / (0.693 * Rc)

The following piece of code measures the discharge time ‘T’, and calculates the Capacitance.

discharge_time_T0 = micros();

discharge_voltage_V1 = discharge_voltage_V0 / 2;

while ( discharge_voltage_V1 <analogRead(A4) );

discharge_time_T1 = micros();

 

capacitance = (discharge_time_T1 – discharge_time_T0) / 0.693;

capacitance = capacitance / resistance_Cr;

 

 

2)      16*2 LCD module

This is a standard 16*2 LCD on which the Arduino displays the capacitance value. The LCD has been wired in four bit mode to reduce the number of output pins of the Arduino board to be used.

Fig. 4: Typical Image of Character LCD

Circuit Description

Fig. 5: Circuit Diagram of Arduino based Capacitance Meter

Code Description

Fig. 6: Flow Chart of Arduino Code for measurement of capacitance

The code first charges the capacitor through an output pin 18, and then removes that charging voltage. The capacitor starts discharging and the code copies the system time at that moment. The same pin18 will be selected as ADC channel to monitor the voltage across capacitor, once it drops below half the original voltage, the code again calculates the time elapsed. Using this value of time the code calculates the capacitance value.

The code running in the Arduino uses the library function micros() to get the system time in microseconds. The capacitance value is then displayed on the 16*2 LCD. The code running in the Arduino uses the library function analogRead()to obtain the ADC values and lcd.print()to display the 16*2 LCD.

 

Project Source Code

###


// include the library code:

#include

 

// initialize the library with the numbers of the interface pins

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

 

int adc_value = 0;

int voltage_peak_value = 0;

int discharge_voltage_V0 = 0;

int discharge_voltage_V1 = 0;

float voltage_average_value = 0;

float dc_voltage_V0 = 0;

float ac_voltage_V0 = 0;

float dc_voltage_V1 = 0;

float dc_voltage_V2 = 0;

float ac_voltage_V1 = 0;

float dc_current_I0 = 0;

float dc_current_I1 = 0;

float ac_current_I0 = 0;

float dc_power = 0;

float ac_power = 0;

float npn_pnp_hfe = 0;

float capacitance = 0;

unsigned long resistance;

unsigned long sample_count = 0;

unsigned long discharge_time_T0 = 0;

unsigned long discharge_time_T1 = 0;

 

void setup()

{

  // set up the LCD's number of columns and rows:

  lcd.begin(16, 2);

  // Print a message to the LCD.

  lcd.print("    EG LABS    ");

  pinMode(13, OUTPUT);

}

void loop()

{

 

 //=============================== CAPACITANCE =====================================

 

  pinMode(18, OUTPUT);

  digitalWrite(18, HIGH);  

  delay(1000);            

  pinMode(18, INPUT);

  discharge_voltage_V0 = analogRead(A4);

 

  discharge_time_T0 = micros();

  discharge_voltage_V1 = discharge_voltage_V0 / 2;

  while ( discharge_voltage_V1 < analogRead(A4) ); 

  discharge_time_T1 = micros(); 

 

  capacitance = (discharge_time_T1 - discharge_time_T0) / 0.693;

  capacitance = capacitance / 100000;

 

  lcd.clear();

  lcd.setCursor(0, 0);

  lcd.print(capacitance);

  lcd.print(" uF");

  

  //=================================================================================

 

  delay(1000);   

}

###

 


Circuit Diagrams

4_1

Project Video


Filed Under: Electronic Projects

 

Next Article

← Previous Article
Next Article →

Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.com forums.



Tell Us What You Think!! Cancel reply

You must be logged in to post a comment.

EE TECH TOOLBOX

“ee
Tech Toolbox: 5G Technology
This Tech Toolbox covers the basics of 5G technology plus a story about how engineers designed and built a prototype DSL router mostly from old cellphone parts. Download this first 5G/wired/wireless communications Tech Toolbox to learn more!

EE Learning Center

EE Learning Center
“engineers
EXPAND YOUR KNOWLEDGE AND STAY CONNECTED
Get the latest info on technologies, tools and strategies for EE professionals.

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


RSS EDABOARD.com Discussions

  • Identification of a 6 pin smd chip (sto-23-6) marked E2
  • Dynacord enter protect
  • IGBTs without negative gate drive
  • Need suggestions in task NI6363 retrigger (analog trigger)
  • Monte-Carlo simulation error on ADE-XL

RSS Electro-Tech-Online.com Discussions

  • Does US electric code allow branching ?
  • Faulty heat air gun (dc motor) - problem to locate fault due to Intermittent fault
  • Fun with AI and swordfish basic
  • Sump pit water alarm - Kicad 9
  • turbo jet fan - feedback appreciated.

Featured – LoRa/LoRaWan Series

  • What is the LoRaWAN network and how does it work?
  • Understanding LoRa architecture: nodes, gateways, and servers
  • Revolutionizing RF: LoRa applications and advantages
  • How to build a LoRa gateway using Raspberry Pi
  • How LoRa enables long-range communication
  • How communication works between two LoRa end-node devices

Recent Articles

  • How IoT network topologies work
  • The top five AI startups to watch in 2025
  • STMicroelectronics unveils SoC based on secure MCU
  • Nexperia’s 48 V ESD diodes support higher data rates with ultra-low capacitance design
  • Taoglas releases Patriot antenna with 18 integrated elements covering 600 to 6000 MHz

EE ENGINEERING TRAINING DAYS

engineering

Submit a Guest Post

submit a guest post
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • Battery Power Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • EV Engineering
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • Subscribe to our newsletter
  • About Us
  • Contact Us
  • Advertise

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy

Search Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe