In this article, we are going to learn how to make a simple voltage protector for your appliances. A small device can save lots of money, saving your appliances from voltage spike/surge/sag and unacceptable voltage range. So let’s make it!

Disclaimer: Electricity is always dangerous. Proper skill is required to work with electricity. Do work at your own risk. The author will not be responsible for any misuse or harmful act or any mistake you make. The contents of this website are unique and copyright protected. Kindly don’t do any nonsensical act copying and claiming it as yours. Most of the articles published here are kept open-source to help you. Take the knowledge for free and use it, but if you are interested you can buy the ready resources offered here. If you need any help or guide feel free to comment below, the author will try to help you. Also, there can be affiliation links in the article. Which will not affect you anyway, but helps the author with some commission. So please don’t take it otherwise. Thanks.

What is spike/surge/sag?

Usually, your home supply voltage is either 220V or 110V depending on your region. But this voltage is not always constant. Due to various issues (like switching a large load or line faults and so on) this line voltage can carry a high or low voltage pulse for a short period of time. A voltage spike is a sudden increase in voltage that lasts for less than three nanoseconds & A sudden increase in voltage that lasts for three nanoseconds or more is called a voltage surge.

Voltage sag on the other hand is similar but a sudden voltage drop due to other loads like a heavy motor or heavy switch is turned on. This may also hamper your appliances creating a sudden voltage drop which can generate a restarting issue.

A surge can burn the internal components of your appliance if there is no protection for the spike. Especially the electronic devices are mostly affected by spike & surge. Sag can also damage your appliance but a burning case is rare. A Sag normally interrupts the operation like your PC can be restarted while you are working on an important task on your PC.

These are sudden problems but besides this, a high or low voltage also can happen.

High/Low voltage effect on appliances:

A high or low voltage can appear on your supply line and can stay for a while. That definitely will damage your appliance if it is out of tolerable range. Some appliances may have internal protection but most of them have nothing.

Low voltage also can damage your appliances especially the inductive loads like motors. Because, due to low voltage the motor can stop rotating and once the rotation is stopped, a high current flows through the coils. That kills the coil.

High voltage can also burn the appliances but inductive loads can take little high voltage for a while without problem. Electronic appliances are mainly get harmed due to high voltage.


For surge/spike, a MOV or metal-oxide varistor can be used. But complete isolation is always better.

A fuse in first and then a MOV in parallel with the load can effectively protect the appliances from the spike.

This can be applied only for spike/surge but for sag, there is no such easy way to prevent it without using some kind of complex circuit. You can convert the AC supply into DC, store it in capacitors, step up a little bit, then again convert this DC into AC. This way sag can be prevented. But in simple, cutting off the line is possible for while.

Our solution:

To make a device to prevent voltage issues, we can use microcontrollers with some associative circuits. A display can make it user-friendly. So let’s make the circuit diagram first.

Circuit diagram:

Circuit Description:

First, you may use any pins serially for the display but here in my circuit, I used without any serial because of my PCB design. I designed keeping in mind the PCB first. Anyway, among other parts of this circuit is a capacitor power supply.

You can read my article on capacitor power supply from here.

This power supply is suitable for small loads like our project here. The benefits of this type of power supply are these are extremely cheap and durable. One can last a long period of time. One of mine is being running since 2014. Here the circuit is simply reducing the AC 220voltage into 12V DC across the D1. Then a 5V regulator makes a 5V output for our MCU. R3 is important for longer operation and R1 is important to reduce inrush current through C1. C1 should be X2 type, but you can use other types of similar ratings if its quality is good.

On the left side, VR1 is a varistor (MOV). You can keep the Fuse and MOV out of the PCB if you want. In my case, I kept it outside PCB and these are direct fit with the input and output line. Relay here is used for bypassing the input to output.

I used some resistors for sensing the line voltage directly as we are not touching the circuit while it is operating. So, we can use resistors for measurement rather than using any other isolation or transformers. The concept is pretty easy, R9 + RV1 are used to make the fine-tune job. & R8+C6 are for the R-C filter.


As I always try to make anything like a usable product, so I design PCBs for them. Similarly here for this project, I designed my PCB and printed it from You can follow my design or you can do it yourself.

And in real life the circuit is:


I use mikroC pro for PIC from programming PIC MCUs. Here is the basic code of our voltage protector.

Program for Dual Display voltage Stabilizer v8.2
Program Written by_ Engr. Mithun K. Das;
Compiler: mikroC pro for PIC v7.6.0; Xtal:8Mhz; Date: 10-04-2021

//pin declerations
#define   a        RB5_bit
#define   b        RB7_bit
#define   c        RC5_bit
#define   d        RB0_bit
#define   e        RC7_bit
#define   f        RB6_bit
#define   g        RB4_bit
#define   dot      RC6_bit

#define   D1       RB1_bit
#define   D2       RB2_bit
#define   D3       RB3_bit

#define  Relay    RC3_bit
#define  LED      RC4_bit

void mark(int digit)
  switch (digit)
     case   0: a=0;b=0;c=0;d=0;e=0;f=0;g=1;dot=1;break;
     case   1: a=1;b=0;c=0;d=1;e=1;f=1;g=1;dot=1;break;
     case   2: a=0;b=0;c=1;d=0;e=0;f=1;g=0;dot=1;break;
     case   3: a=0;b=0;c=0;d=0;e=1;f=1;g=0;dot=1;break;
     case   4: a=1;b=0;c=0;d=1;e=1;f=0;g=0;dot=1;break;
     case   5: a=0;b=1;c=0;d=0;e=1;f=0;g=0;dot=1;break;
     case   6: a=0;b=1;c=0;d=0;e=0;f=0;g=0;dot=1;break;
     case   7: a=0;b=0;c=0;d=1;e=1;f=1;g=1;dot=1;break;
     case   8: a=0;b=0;c=0;d=0;e=0;f=0;g=0;dot=1;break;
     case   9: a=0;b=0;c=0;d=0;e=1;f=0;g=0;dot=1;break;
     case  10: a=1;b=1;c=1;d=1;e=1;f=1;g=1;dot=1;break;

void InitTimer0()
  OPTION_REG     = 0x82;
  TMR0           = 68;
  INTCON         = 0xA0;

int cnt=0,disp_digit[6];
unsigned int number1=0,number=0;
unsigned int display1=0,display2=0;
bit dot_en,delay_toggle;
int min=0,sec=0,loop;
unsigned int line_voltage=0,output_voltage=0;
long max_point=0,temp=0,line_voltage_raw=0,output_voltage_raw=0;
unsigned int k=0,i=0;

void convert_digit()
   disp_digit[0] = number/100u;
   disp_digit[1] = (number/10u%10u);
   disp_digit[2] = (number/1u%10u);


void Interrupt() iv 0x0004 ics ICS_AUTO
  if (TMR0IF_bit)
      TMR0IF_bit = 0;
      TMR0  = 68;

      number = display1;

         D1 = 1; D2 = 0; D3 = 0;
      else  if(cnt==3)
         D1 = 0; D2 = 1; D3 = 0;
      else  if(cnt==5)
         D1 = 0; D2 = 0; D3 = 1;

         D1 = 0; D2 = 0; D3 = 0;

         cnt = 0;

void Read_input_voltage()
     //read input voltage
     ADCON1 = 0x04;
     ADCON0 = 0x01; //AN0
     line_voltage_raw = 0;

               max_point = temp;
            asm CLRWDT;
         line_voltage_raw+= (max_point*218/151);
         asm CLRWDT;
     line_voltage=(int)line_voltage_raw/10; //get average value
     ADCON1 = 0x07;
     ADCON0 = 0x00; //AN0


void main()
  TRISA = 0b00010011;
  TRISB = 0x00;
  TRISC = 0x00;//all output
  PORTC = 0x00;
  PORTB = 0xFF;

  ADCON1 = 0x04;//ADC settings

  display1 = 0;
  Delay_ms(15000);//initial delay for 15s



     display1 = line_voltage;
     if(line_voltage>175 && line_voltage<245)
         LED = 1;
         Relay = 1;
        LED = 0;
        Relay = 0;

}//end of void main()


Once you learn this basic code, you can add other features with this product as I did in mine. But this basic code also works fine with your circuit.

There are other functions you can add like delay display, high or low voltage indication, transient trip, permanent trip, and so on.


Here is my product, I tested with added features.

If you are interested in this project, you can make one for yourself using the above resources. Besides, if you are interested to use my design files and codes, you can buy them from here too.


You can make one or you can get one, it’s your choice. I gave you both options. But to make a product it needs time and money, so if you want to get one you should pay a little for that. But it’s not forced on you at least. It’s your choice. Anyway, if you read the above article, it will be easy to make your own voltage protector. Thanks, see you in the next article soon.


Also let me know what you want to get as the next article, comment below!

You may read this article too: Voltage Stabilizer Circuit with 4 Relays.


Mithun K. Das; B. Sc. in EEE from KUET; Head of R&D @ M's Lab Engineering Solution. "This is my personal blog. I post articles on different subjects related to electronics in the easiest way so that everything becomes easy for all, especially for beginners. If you have any questions, feel free to ask through the contact us page." Thanks.


R K Hamy · 24/10/2021 at 10:57 am

Many Thanks.

Joy · 25/10/2021 at 8:27 am

Nice. Many Many Thanks.

Moses · 16/12/2021 at 1:47 pm

Sir l do not want the mcu display part. I want to use 3LED OF DIFFERENT COLORS to indicate high, low and normal voltage. Please can you design a schematic for me in that respect just from the one you have given here above.

    MKDas · 18/12/2021 at 10:44 am

    Simply use 3 LEDs from the pins used for the segment.

Dinesh · 30/12/2021 at 9:28 pm

what is the function of 470k resistor between neutral and ground in schematic..?

Leave a Reply

Avatar placeholder

Your email address will not be published.