AC 220V Frequency counter using arduino

In this project i used Arduino and some other electronic components for AC mains frequency measurement.
Since Frequency is equal to: 1 divided by time period, so in first we should measure the time period. Time Period is the time of one full wave in AC voltage, means positive half wave+negative half wave.
Here i used optocoupler for detecting the frequency of AC voltage. 47K resistor decrease the current to about 5mA for running the optocoupler and one diode for half wave rectification  So the arduino here calculate the ON time and OFF time of optocoupler that connected to Pin 13 in arduino board, then divided 1 by (ON+OFF) Time for give the frequency. 
Since in arduino code the time always must insert as millisecond so we devide 1000 by ON+OFF Time for give the frequency.
The circuit 100% insulated from mains voltage and can not be harmful for your arduino board.
You can use any other available optocoupler rather than 817B. 

AC 220V Frequency counter using arduino

Parts list: 
Arduino board
LCD display 16x2
Resistor 10K
Resistor 220 ohm
Resistor 47K / 1W
Diode 1N4007
Potentiometer 10K
Optocoupler 817B or any optocoupler  

NOTE: Don't touch the circuit when it connected to mains voltage.
 
AC 220V Frequency counter using arduino

AC 220V Frequency counter using arduino

Please subscribe to my YouTube channel here: 




Code:

 #include <LiquidCrystal.h>
int input=13;

int high_time;
int low_time;
float time_period;
float freq;
float frequency;
LiquidCrystal lcd(0, 1, 3, 4, 5, 6);
void setup()
{
pinMode(input,INPUT);
lcd.begin(16, 2);
}
void loop()
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Frequency Meter");

high_time=pulseIn(input,HIGH);
low_time=pulseIn(input,LOW);


time_period=high_time+low_time;
time_period=time_period/1000;
frequency=1000/time_period;
lcd.setCursor(0,1);
lcd.print(frequency);
lcd.print(" Hz");
delay(500);
}

Komentar

Postingan populer dari blog ini

Using ultrasonic sensor without arduino

Power saving relay driver

Electronic load using Op-Amp IC 358