Wednesday, November 23, 2016

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


 #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()
lcd.begin(16, 2);
void loop()
lcd.print("Frequency Meter");


lcd.print(" Hz");