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:
- Simple Digital Voltmeter Circuit with PCB using ICL7107
- LM3914 Voltmeter Circuit
- 0-25V Digital Voltmeter using AVR Microcontroller
- One 12-0-12 transformer
- 1N4007 diode
- 1uf capacitor
- Resistors 10k; 4.7k.
- Zener diode(5v)
- Arduino UNO
- Connecting wires
Arduino Voltmeter Circuit Diagram:
Circuit Diagram for this Arduino Voltmeter is shown above.
- Connect high voltage side(220V) of transformer to the mains supply and low voltage(12v) to the voltage divider circuit.
- Connect 10k resistor in series with 4.7k resistor but make sure to take voltage as input across 4.7k resistor.
- Connect diode as shown.
- Connect capacitor and zener diode across 4.7k
- 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.
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).
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.
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
int m;// initialise variable m
float n;//initialise variable n
pinMode(A0,INPUT); // set pin a0 as input pin
Serial.begin(9600);// begin serial communication between arduino and pc
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