How To Make A Voltmeter Using Arduino
In order to measure voltages greater than the 5 V reference voltage, you need to divide the input voltage so that the voltage actually input to the Arduino is 5 V or less. in this experiment, we will use a 90.9 kohm resistor and a 10 kohm resistor to create a 10:1 divider. This will allow us to measure voltages up to 50 V.
Hardware Required
- 1x Arduino UNO
- 1x 90.9 kohm resistor
- 1x 10 kohm resistor
- 1x LCD (Liquid Crystal Display)
- 1x 5k potentiometer
- 1x breadboard
- female connector
- jumper wires
Wiring Diagram
Code
#include <LiquidCrystal.h>
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
float input_voltage = 0.0;
float temp=0.0;
float r1=90900.0;
float r2=10000.0;
void setup()
{
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
lcd.begin(16, 2); // set up the LCD's number of columns and rows:
lcd.print("DIGITAL V METER");
}
void loop()
{
//Conversion formula
int analog_value = analogRead(A0);
temp = (analog_value * 5.0) / 1024.0;
input_voltage = temp / (r2/(r1+r2));
if (input_voltage < 0.1)
{
input_voltage=0.0;
}
Serial.print("v= ");
Serial.println(input_voltage);
lcd.setCursor(0, 1);
lcd.print("Voltage= ");
lcd.print(input_voltage);
delay(300);
}