In this project I will show how I built a automatic power switching system that will switch a device to another power source if grid power fails.
The circuit works by sensing the voltage on the grid side of the circuit and if it fall below a certain voltage the relays the transfer the load to the backup power source. When the power is lost on the grid the relay for the grid turns off and then the relay turns on for the backup supply. It is important that the supply from the grid is disconnected by the first relay before the second relay for the backup source is turned on.
This circuit will work with AC power but if you would like to use this as a backup switch for a DC powered device then you can change the transformer based voltage sensor with some resistors to step down the DC voltage if you would like to use this for DC then check out my other project 'measuring voltage, current and resistance using an Arduino' on how to do this.
Make sure that the screw terminals you are using are rated for the amount of current that your device will draw. The device will automatically switch back to grid power when the supply has been restored.
CodeI have written some code for the project to run. I programmed my microcontroller by inserting the IC into an Arduino and then uploading the code with the Arduino IDE.
The code is written for 240v so if you have a supply voltage less than 240 volts you will need to change the code. I would suggest to set the limit 10V-20V below your voltage.
int main = 12
int backup = 13
void setup() {
int pinMode(main , OUTPUT)
int pinMode(backup , OUTPUT)
}
void loop() {
int Input = analogRead(A0); // Read the analog value
double voltage = Input * (5.0 / 1024.0) * 100; //convert the value to volts.
//Adjust the trim pot on the sensor to set the output to 100V = 1V
if (voltage < 220) digitalWrite(Main, HIGH);
if else ((voltage > 220)
{
digitalWrite(main, LOW);
delay (10)
digitalWrite(backup, HIGH);
}
AcknowledgementI thank PCBWay & LCSC Electronics for the partnership.
PCBWay Is a cheap reliable service where you can get your PCBs manufactured. All the PCBs are high quality and the engineers are very helpful and will resolve any problems you may have quickly. Sign up today and get a $5 welcome bonus. Check Out PCBWay Hackster page.
LCSC Electronics Is China's leading Electronic Components Distributor. LCSC sells a wide variety of high quality electronic components at low prices. With over 150, 000 parts in stock they should have the components you need for your next project. Sign up today and get $8 off on your first order.
WebsiteCheck out more of my other projects on my website.
Comments
Please log in or sign up to comment.