HELP TO KNOW MONITOR THE FREQUENCY OF THE SINGLE PHASE 22OV,50hz

I have been monitoring my domestic connection voltage (229V, 50Hz) by using the attached voltage sensor circuit with the arduino uno and this code

// AC Voltmeter 

#include <LiquidCrystal.h>

// LCD Initialization
LiquidCrystal lcd(8,9,4,5,6,7);
#define LCD_WIDTH 16
#define LCD_HEIGHT 2

// ADC
int adcPin = A5;
int adcValue = 0;

int variation= 300;
int rmsVoltage;

int relayPin = 12;

void setup()
{
  lcd.begin(LCD_WIDTH, LCD_HEIGHT);
  pinMode(relayPin, OUTPUT); 
  
}

// Main loop
void loop()
{
 adcValue = analogRead(adcPin);
 rmsVoltage = (adcValue*variation)/1024;
 
 // Display Voltage 
 lcd.print("Voltage = ");
 lcd.print(rmsVoltage);
 delay(30);
  
 if( rmsVoltage >280 || rmsVoltage< 180 ){
   // Energize relay
     digitalWrite(relayPin, HIGH);
 }
 else{
     digitalWrite(relayPin, LOW);
 }
   
  
  
}

How I can monitor the frequency of the line voltage ?
Do I have to add some more parts and what formula I should use ?

voltage_1.jpg

WHY DO YOU NEED TO SCREAM? Please edit the title.

And which attached circuit?

But if you want to know the frequency you need to measure the time between two known places of the sine. The zero crossing would be the easiest option. So start timing when you see a zero crossing and stop timing when you see a zero crossing again. Then you know the time of halve a sine wave. Then f = 1 / (2 x t)

But I don't know if your circuit can even do that now...

Hi,
Google Arduino zero crossing detector

Your method has the Arduino connected directly to the mains circuit, not just to monitor the voltage but to power the Arduino, I would consider this very dangerous.

Not a good idea, and not very safe.

I would suggest you power your Arduino with a USB power adapter.
Use a small 240Vac to 5Vac tranformer to monitor the mains voltage and detect zero crossing, to measure frequency.

Tom... :slight_smile:
OPs diagram
voltage_1.jpg

voltage_1.jpg

Wow, that image is tiny.

As long as you know what you're doing voltage wise, connecting it to mains is fine. But don't accidentally try to program it while it's connected. That will turn of the lights.

And I don't see how that voltage sense is going to work. No voltage divider but I do see a zener... How is that giving you a voltage reading?