Showing posts with label best arduino projects. Show all posts

Capacitance Meter for Range 1 µF to 4700 µF

Circuit Diagram



Components Required

  • Arduino UNO 
  • 16 x 2 LCD Display
  • 10 KΩ Potentiometer 
  • 10 KΩ Resistor (1/4 Watt) 
  • 220 Ω Resistor (1/4 Watt)
  • Breadboard 
  • Connecting wires 
  • Power supply 
  • Capacitor under test 

Working Principle

In order to measure the capacitance in the range of 1 µF to 4700 µF, we have to use the above circuit. Before explaining the working of the project, we will first see the principle behind this method of capacitance measurement.
The principle behind this capacitance meter lies in one of the basic property of the capacitor: The Time Constant. Time Constant (denoted by Greek Alphabet Tau – τ) is defined as the time taken to charge a capacitor (C) through a resistor (R) to reach 63.2 % of the maximum supply voltage.
Alternatively, the Time Constant (τ) of a capacitor can also be defined as the time taken by a fully charged capacitor C to discharge to 36.8 % of its maximum voltage through a resistor R.
Smaller capacitors will have less time constant as they take less time to charge. Similarly, larger capacitors will have higher time constants.
Mathematically, Time Constant TC or τ = R x C (τ = RC).
Here, τ or TC is the time constant of Capacitor in seconds (s), C is the Capacitance of the Capacitor in Farads (F) and R is the Resistance of the Resistor in Ohms (Ω).
The following circuit and graph will show you the time constant curve for a Capacitor C, charging to supply voltage V through a Resistor R.




We use the same concept in our Arduino based Capacitance Meter. We will charge an unknown capacitor through a known resistance using Arduino pins and calculate the time it takes to reach 63.2 % of supply voltage (3.1 V approximately). Based on the time, we can calculate the Capacitance from the formula C = τ / R.
We will use a 10 KΩ Resistor to charge the capacitor and a 220 Ω Resistor to discharge it. The charge and discharge pins on Arduino are 8 and 9 respectively. The voltage across the capacitor is measured using the Analog Input pin A0.
Initially, we will discharge the capacitor using pin 9 (by setting it as OUTPUT and LOW) to make sure that the capacitor has no charge. We will then start the timer and charge capacitor using the charge Pin8 (by setting it as OUTPUT and HIGH).
Now, we have to monitor the voltage across the capacitor at the analog pin and once it reaches 63.2% of 5V (approximately 648 from analog pin), we have to stop the timer and calculate the capacitance.
This circuit is suitable for comparatively higher capacitance values as we can clearly measure the time constant. For smaller capacitance values, this circuit might not be suitable.

Code


#include <LiquidCrystal.h>
LiquidCrystal lcd(6, 7, 2, 3, 4, 5);
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;
float answer=0.0;
int measure (void);
/////////////////////////////////
void setup()
{
Serial.begin(9600);
lcd.begin(16, 2);
lcd.print("RANGE 1uF-4700uF");
lcd.setCursor(0,1);
lcd.print("place capacitor ");
pinMode(discharge,INPUT);
pinMode(charge,OUTPUT);
digitalWrite(charge,HIGH);
}
//1021 1022 1023
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)
{
//////////////////////////////////////////////discharging
pinMode(charge,INPUT);
pinMode(discharge,OUTPUT);
digitalWrite(discharge,LOW);
lcd.setCursor(0,1);
lcd.print("Discharging-");//12
while(voltage>2.0)
{
voltage=measure();
delay(100);
lcd.setCursor(12,1);
answer=voltage * (99.0 / 1023.0);
lcd.print((99-answer),0);
lcd.setCursor(14,1);
lcd.print("%");
}
lcd.setCursor(0,1);
lcd.print(" ");
delay(1000);
lcd.setCursor(0,1);
lcd.print("charging-");//9
lcd.setCursor(13,1);
lcd.print("%");
//////////////////////////////////////////////charging
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;
answer=duration/10000;
lcd.clear();
// lcd.setCursor(0,1);
// lcd.print(" ");
lcd.setCursor(0,0);
lcd.print("value = ");
lcd.print(answer);
lcd.print("uF");
delay(3000);
while(1)
{
lcd.setCursor(0,1);
lcd.print("reset to measure");
delay(200);
lcd.setCursor(0,1);
lcd.print(" ");
delay(200);
}
}
}
int measure (void)
{
int value;
value=analogRead(analogPin);
return value;
}

Circuit Diagram of Automatic Room Lights using Arduino

The following image shows the circuit diagram of the project implemented using Arduino UNO, PIR Sensor and a Relay Module.


If you do not have a relay module, you can make one yourself using very simple hardware. The following circuit diagram shows the project being implemented with the help of discrete components for the Relay Module.



CAUTION: The project involves connection with 230V AC Mains (or 110V, depending on where you live!!!). Be extremely careful when connecting the bulb and Relay to mains supply. If you are unfamiliar with the connections, I strongly recommend having an adult supervision (or an expert supervision).  

Components Required for Automatic Room Lights using Arduino

  • Arduino UNO 
  • PIR Sensor 
  • 5V Relay Module (Relay Board) 
  • LED 
  • 100Ω Resistor (1/4 Watt)  
  • Connecting Wires 
  • Breadboard 
  • Power Supply 
If you do not have a Relay Module, use the following components:
  • 5V Relay  
  • 2N2222 (or BC547) NPN Transistor 
  • 1N4007 PN Junction Diode 
  • 1KΩ Resistor (1/4 Watt) 

Component Description

PIR Sensor

We have already seen about PIR Sensor in the PIR Motion Sensor Tutorial and also implemented in a variety of projects like Home Security System and Automatic Door Opener.

Relay Module

A Relay Module is a very useful component as it allows Arduino, Raspberry Pi or other Microcontrollers to control big electrical loads. We have used a 2-channel Relay Module in this project but used only one relay in it. The relay module used in this project is shown below.

In order to control a single relay on the board, we need to use three pins of the relay module: VCC, GND and IN1.


NOTE: The relay module used in this project is as active LOW one i.e. when the IN1 pin is HIGH, the relay is OFF and when it is LOW, the relay is activated. This point is important while programming the Arduino UNO.

Circuit Design

PIR Sensor’s Data OUT Pin is connected to Arduino’s Digital I/O Pin 8. An LED is connected to pin 13 of Arduino to indicate whether the light is turned ON or OFF.
The IN1 pin of the Relay Module is connected to Pin 9 of Arduino. A bulb is connected to mains supply through relay. One terminal of the bulb is connected to one wire of the mains supply. The other terminal of the bulb is connected to the NO (Normally Open) contact of the Relay Module.
COM (Common) contact of the Relay is connected to the other wire of the mains supply. Be careful when connecting this part of the project.

Code

The code for the Automatic Room Lights using Arduino and PIR Sensor is given below.

MARI themes

Powered by Blogger.