Voltage under over curoff

Good morning

I need assistance
I am using the chip from the arduino uno.
I will then build my own circuit for the unit.
What i am currently looking for is the ac monitoring with a over and under voltage cutoff.
Our voltage is all over the place some areas over 250v and others drop to under 160
I want 190 and 250 to be the cutoff and stop the supply to appliance.
I am still new to Arduino and really struggeling with this one.
Also want to keep the cost low if i have a spike that it blows the unit that its cheap to build again.
Thank you for your assistance.

What sensors are you using. What code have you written. Do you have a schematic?

I was looking at using this to monitor the voltage and then just adding a relay.
Then also to change the code to turn the relay on and off.
Do you think this would work or is there something else you can suggest.

int m;// initialise variable m
float n;//initialise variable n

void setup()
{
pinMode(A0,INPUT); // set pin a0 as input pin
Serial.begin(9600);// begin serial communication between arduino and pc
}

void loop()

{

  m=analogRead(A0);// read analog values from pin A0 across capacitor

n=(m* .304177);// converts analog value(x) into input ac supply value using this formula ( explained in woeking section)

Serial.print(" analaog input " ) ; // specify name to the corresponding value to be printed
Serial.print(m) ; // print input analog value on serial monitor
Serial.print(" ac voltage ") ; // specify name to the corresponding value to be printed

Serial.print(n) ; // prints the ac value on Serial monitor
Serial.println();

}

This is the code i want to use do i add a relay so when the voltage is under 190 volts or over 250 volts is cuts the connection to the appiance.

Edit your post :pencil2: to use code tags <|>

Where do i need to add those?

RMS Voltage Sensor Part 3: Arduino Code - YouTube

Plus

All the usual caveats about AC mains dangers :grimacing: