AC Voltmeter using Arduino

Published  August 20, 2017   26
AC Voltmeter using Arduino
AC Voltmeter using Arduino

In this project, we are going to make an AC Voltage Measuring Device using Arduino, which will measure the voltage of Alternating Current Supply at our home.  We are going to print that voltage on serial monitor of Arduino IDE as well as show on the multimeter.

Making a Digital Voltmeter is a lot easy than making an analog one because in case of analog voltmeter you must have good knowledge of physical parameters like torque, friction losses etc. whereas in case of digital voltmeter you can just use a LCD or LED matrix or even your laptop (as in this case) to print the voltage values for you. Here are some Digital Voltmeter Projects:

Required Components:

  1. One 12-0-12 transformer   
  2. 1N4007 diode   
  3. 1uf capacitor   
  4. Resistors 10k; 4.7k.   
  5. Zener diode(5v)   
  6. Arduino UNO   
  7. Connecting wires

Arduino Voltmeter Circuit Diagram:

AC voltmeter using Arduino circuit diagram

Circuit Diagram for this Arduino Voltmeter is shown above.

Connections:

  1. Connect high voltage side(220V) of transformer to the mains supply and low voltage(12v) to the voltage divider circuit.
  2. Connect 10k resistor in series with 4.7k resistor but make sure to take voltage as input across 4.7k resistor.
  3. Connect diode as shown.
  4. Connect capacitor and zener diode across 4.7k
  5. Connect a wire from n-terminal of diode to the analog pin A0 of Arduino.

** Note:  Do connect ground pin of Arduino to the point as shown in the figure or circuit will not work.

AC-voltmeter-using-Arduino Transformer for AC voltmeter using Arduino

measuring voltage with multimeter AC voltmeter using Arduino measuring voltage in serial monitor AC voltmeter using Arduino

Need of voltage divider circuit?

As we are using 220/12 v transformer, we get 12 v on l.v side. Since this voltage is not suitable as input for Arduino we need a voltage divider circuit which can give suitable voltage value as input to Arduino

.

Why diode and capacitor is connected?

Since Arduino do not take negative voltage values as input, we first need to remove negative cycle of step down AC so that only positive voltage value is taken by Arduino. Hence diode is connected to rectify the step down voltage. Check our Half wave rectifier and Full wave Rectifier circuit to learn more about rectification.

This rectified voltage is not smooth as it contains large ripples which cannot give us any exact analog value. Hence capacitor is connected to smooth out the a.c signal.

Purpose of zener diode?

Arduino can get damage if voltage greater than 5v is fed to it. Hence a 5v zener diode is connected to ensure safety of Arduino which breakdowns in case this voltage exceeded 5v.

Working of Arduino based AC Voltmeter:

1. Step down voltage is obtained on l.v side of transformer which is suitable to use across normal power rating resistors.

2. Then we get suitable voltage value across 4.7k resistor

Maximum voltage that can be measured is found by simulating this circuit on proteus (explained in simulation section).

3. Arduino takes this voltage as input from pin A0 in form of analog values between 0 to 1023. 0 being 0 volt and 1023 being 5v.

4. Arduino then converts this analog value into corresponding mains a.c. voltage by a formula. (Explained in code section).

Simulation:

AC-voltmeter-using-Arduino-simulation-311V

Exact circuit is made in proteus and then simulated. To find maximum voltage that this circuit can measure hit and trial method is used.

On making alternator’s peak voltage 440 (311 r.m.s), voltage on pin A0 was found to be 5 volts i.e. maximum. Hence this circuit can measure maximum 311 r.m.s voltage.

Simulation is performed for various voltages between 220 r.m.s to 440v.

Simulating AC 285 RMS voltage using AC Arduino Voltmeter

Code Explanation:

Complete ArduinoVoltmeter Code is given at the end of this project and it is well explained through the comments. Here we are explaining few part of it.

m is the input analog value received on pin A0 i.e.,

m=    pinMode (A0,INPUT) ;  // set pin a0 as input pin

To assign variable n to this formula n=(m*.304177),  first some sort of calculations is performed by using the data obtained in simulation section:

As seen in simulation photograph, 5v or 1023 analog value is obtained at pin A0 when input a.c voltage is 311volts. Hence:

1023 analog value corresponds to 311 volt mains supply

So any random analog value corresponds to (311/1023)*m where m is obtained analog                value.

Hence we arrive at this formula:

n=(311/1023)*m volts or n=(m*.304177)

Now this voltage value is printed on the serial monitor by using serial commands as explained below. And also shown on the multimeter as demonstrated in the Video below.

Values printed on the screen are:

Analog input value as specified in the code:

Serial.print("   analog input  ") ; // this gives name which is “analog input”  to the printed analog value 

Serial.print(m);// this simply prints the input analog value

Required a.c voltage as specified in the code:

 Serial.print("   ac voltage  ") ; // this gives name  “ac voltage”  to the printed analog value 

 Serial.print(n) ;  // this simply prints the ac voltage value
Code

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();
}

Video

Have any question realated to this Article?

Ask Our Community Members

Comments

Submitted by Xyzz on Fri, 04/06/2018 - 15:34

Permalink

If we increase the supply ac voltage above 230v for checking overvoltage condition using arduino, then with respect to that increased voltage will the arduino recognize the fault of overvoltage or will the input given to arduino will also change with respect to changed supply voltage???

Submitted by Malefetsane on Fri, 04/13/2018 - 20:20

Permalink

hi

van I use arduino to make over voltage load protection??

Submitted by Moch Rizky Maulana on Mon, 05/07/2018 - 16:08

Permalink

good evening i wanna ask how the result can be stable in 234. i try to make this but the result cant stable. can you have solution or help me ?

Submitted by Dmitry on Wed, 05/23/2018 - 22:57

Permalink

Hello all! How to make it work at higher (40 kHz) frequency and lower (<5V ) voltage?

Submitted by Vikas D on Wed, 06/06/2018 - 12:44

Permalink

Great work!!!!!
what is the specification for transformer ??
current and voltage

Submitted by Rudi on Thu, 06/28/2018 - 23:48

Permalink

Why do you use a 220/12V transformer?

Would it not be more accurate if you made a voltage divider to divide 220V (or 240V?) to 5V?

No,

Voltage divider are used only for getting a voltage signal. It cannot be used as a power source. Meaning you cannot (should not) draw power from a voltage divider circuit.

The transformer is also for SAFETY reasons. If you use a potential divider connected directly to the mains voltage that would be very dangerous. One fault and the whole circuit could become live. In addition some countries have two live wires/phases instead of live and neutral. You cannot safely assume that "Neutral" is the same voltage as the 0V from the Arduino power supply or USB. Do NOT omit the transformer.

Submitted by Asaduzzaman on Wed, 08/08/2018 - 14:03

Permalink

Can I measure current milliampere range by this arrangement??

Hello! How to set value of these transformer parameters in proteus for 220/12 V?

Primary Inductance

Secondary Inductance

Coupling Factor

Primary DC resistance

Secondary DC resistance

Hey man,

what are configuration for transformer in proteus?

Primary Inductance

Secondary Inductance

Coupling Factor

Primary DC resistance

Secondary DC resistance

 

if i check directly on voltmeter it is showing 214 volts ... while on my serial monitor it is showing 311 volts... kindly help out