Voltage Monitoring and Automatic Power Cut Off

I am planning to create a device (that is kinda like an adapter) that monitors the voltage used by an appliance and cuts off the power (which turns off the appliance) automatically when the voltage consumption of the said appliance exceeds a certain value.

I am very new to Arduino so I wanted to have at least a rough plan (and code) first before actually buying the materials for this project. I stumbled upon a video by Bas on Tech (VOLTAGE SENSOR (0-25V) - Arduino tutorial #17 - YouTube), I copied the code he used but modified some parts. I just wanted to ask if this would theoretically work.

Here is the code

float vIn;                                // measured voltage (3.3V = max. 16.5V, 5V = max 25V)
float vOut;
float voltageSensorVal;                   // value on pin A3 (0 - 1023)
const float factor = 5.128;               // reduction factor of the Voltage Sensor shield
const float vCC = 5.00;                   // Arduino input voltage (measurable by voltmeter)
float totV = 0;                           // Where the total voltage value will be stored

void setup() {
  Serial.begin(9600);
}

void loop() {

  voltageSensorVal = analogRead(voltageSensorPin);    // read the current sensor value (0 - 1023) 
  vOut = (voltageSensorVal / 1024) * vCC;             // convert the value to the real voltage on the analog pin
  vIn =  vOut * factor;                               // convert the voltage on the source by multiplying with the factor

  totV += vIn;

  Serial.print("Current Voltage = ");             
  Serial.print(vIn);
  Serial.println("V\n");
  Serial.println("Total Voltage = ");
  Serial.println(totV);
  Serial.println("V");

  if (totV >= 120) {
    cut();
  } 
  delay(1000);
}

void cut() {                                           // the function to cut power supply  
                                                     
}

His code gives off a continuous stream of Voltage values so I created a variable totV to store and add up those values. And if it reaches 120 (in this example), I would then execute the cut() function which should cut the power. Also, if you have any ideas on ways to cut the current, any help would be appreciated.

Hello akosiibarra
Connect a potiometer to your hardware setup and see what happens by testing yourself.
Have a nice day and enjoy coding in C++.

Why would the voltage change? Normally appliances run from a stable source of electricity (eg mains) and the CURRENT consumption changes.

So what is this mysterious "appliance"?

Hi, @akosiibarra

As @johnerrington has pointed out you may be having problems with electrical terms.
A load consumes current.
A power supply provides potential, voltage, and the current, amps, that the load needs.

What is you application?
What is your power source?

Thanks.. Tom... :grinning: :+1: :coffee: :australia:

Thanks @paulpaulson

Hello @TomGeorge , I am still a high school student focused in coding and we can all agree that I am having problems with electrical terms, lol. What I'm trying to achieve in this project is an adapter(?) device that detects whether an appliance reaches the maximum electrical consumption that the user wants. And when it does, the power automatically cuts off. I don't know if that was a clear explanation because I have never been exposed to the topic of electricity. But basically, my device is for the people wanting to save money by reducing their electrical bills.

Hi @johnerrington @TomGeorge , if my explanation was still unclear, here is a similar device. Auto Power Cut Off Switch - YouTube But instead of a timer, I wanted to measure the electrical consumption of the appliance and cut off the power whenever it reaches a certain value. Thanks for the response.

People use a timer for that (for example, you can buy heater timers at home improvement stores). Electricity is sold by the kilowatt-hour.

Oh okay, I guess I'll be using a timer for this device. Thanks @jremington

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.