Build an Arduino Uno digital voltmeter for 0 to 25 V DC with a voltage divider, I2C LCD and bar graph. Wiring table, diagram and full commented code.
Need it ready-made? Buy Ready Project

This Arduino digital voltmeter measures a DC voltage from 0 to 25 V and shows it on a 16×2 I2C LCD with a live bar graph. It uses only an Arduino Uno (ATmega328P), two resistors that form a voltage divider and an LCD, so it is a great first measurement project.
The Arduino analog input can only read up to 5 V. The divider cuts the input voltage by a factor of five, the code multiplies it back, and averaging 20 readings keeps the display steady.
How the Digital Voltmeter Works
- Voltage divider: R1 = 30 kΩ and R2 = 7.5 kΩ give a ratio of 5, so 25 V at the input becomes 5 V at pin A0.
- ADC reading:
analogRead()returns 0 to 1023 for 0 to 5 V. The code averages 20 samples to reduce noise. - Formula: Vin = (ADC × 5.00 / 1023) × (R1 + R2) / R2.
- Display: the first LCD line shows the voltage with two decimals and the second line shows a bar graph of the 0 to 25 V range.
- Over-range warning: if the reading goes above 25 V, the LCD shows a warning message.
Components Required
- Arduino Uno (ATmega328P) – 1
- 16×2 LCD with I2C backpack (PCF8574) – 1
- 30 kΩ resistor, 1% if possible – 1
- 7.5 kΩ resistor, 1% if possible – 1 (or use 10 kΩ + 2.5 kΩ in series combinations)
- Breadboard and jumper wires
- DC source to measure, such as a 9 V battery or a 12 V adapter
- USB cable
Wiring Table (Pin-to-Pin)
| Part | Arduino pin | Notes |
|---|---|---|
| R1 (30 kΩ), one end | Input (+) | Positive of the voltage being measured |
| R1 other end / R2 top | A0 | Divider middle point |
| R2 (7.5 kΩ) bottom end | GND | Also connect the negative (–) of the source here |
| LCD SDA | A4 | I2C data |
| LCD SCL | A5 | I2C clock |
| LCD VCC | 5V | Power for the LCD backpack |
| LCD GND | GND | Common ground |
Connection Diagram
The drawing shows each connection from the wiring table. Always connect the ground of the measured source to the Arduino GND, or the reading will be wrong.
Arduino Code
Install the LiquidCrystal I2C library from the Library Manager, select Arduino Uno and upload the sketch below. The code is fully commented and compiles without errors for the Arduino Uno.
/*
Arduino Uno Digital Voltmeter (0-25 V DC) with 16x2 I2C LCD
Voltage divider: R1 = 30 kOhm (to the input), R2 = 7.5 kOhm (to GND)
Divider ratio = (R1 + R2) / R2 = 5.0
Measuring point: A0. LCD (I2C): SDA = A4, SCL = A5, address 0x27
*/
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2); // change to 0x3F if the LCD stays blank
const int VOLT_PIN = A0; // analog input from the divider
const float R1 = 30000.0; // top resistor (ohms)
const float R2 = 7500.0; // bottom resistor (ohms)
const float VREF = 5.00; // measure your 5V pin and put the value here
const int SAMPLES = 20; // readings averaged for a stable result
const int BAR_CELLS = 16; // LCD columns used for the bar graph
void setup() {
lcd.init();
lcd.backlight();
lcd.setCursor(0, 0);
lcd.print("Digital Voltmeter");
lcd.setCursor(0, 1);
lcd.print(" 0 - 25 V DC ");
delay(1500);
lcd.clear();
}
// Average several ADC readings to reduce noise
float readVoltage() {
long sum = 0;
for (int i = 0; i < SAMPLES; i++) {
sum += analogRead(VOLT_PIN);
delay(2);
}
float adc = sum / (float)SAMPLES; // 0 - 1023
float vPin = adc * VREF / 1023.0; // voltage at A0 (0 - 5 V)
return vPin * (R1 + R2) / R2; // real input voltage
}
void loop() {
float v = readVoltage();
if (v < 0.05) v = 0.0; // hide tiny noise near zero
lcd.setCursor(0, 0);
lcd.print("Voltage:");
lcd.print(v, 2);
lcd.print(" V ");
// Bar graph on the second line
int filled = (int)((v / 25.0) * BAR_CELLS + 0.5);
if (filled > BAR_CELLS) filled = BAR_CELLS;
lcd.setCursor(0, 1);
for (int i = 0; i < BAR_CELLS; i++) {
lcd.print(i < filled ? (char)255 : ' ');
}
// Warn when the input is above the safe range
if (v > 25.0) {
lcd.setCursor(0, 1);
lcd.print("OVER RANGE! >25V");
}
delay(300);
}
Calibration Tips
- Measure the real voltage on the Arduino 5V pin with a multimeter and enter it as
VREF. - Measure the real values of R1 and R2 and update
R1andR2in the code. - Compare with a multimeter at 5 V, 9 V and 12 V. Small errors of 1 to 2 percent are normal.
Troubleshooting
| Problem | Fix |
|---|---|
| LCD is blank | Turn the contrast screw on the I2C backpack, or change the address from 0x27 to 0x3F. |
| Reading is always 0 | Check that the source negative is joined to Arduino GND and that the divider middle goes to A0. |
| Reading jumps around | Add a 100 nF capacitor between A0 and GND and use shorter wires. |
| Value is too high or low | Calibrate VREF, R1 and R2 as shown above. |
Safety and Ideas to Extend
- This circuit is for DC only and up to 25 V. Do not connect mains AC.
- Add a 5.1 V Zener diode from A0 to GND for extra protection of the input.
- Add a buzzer for a low-battery alarm, or log values to the Serial Monitor.
FAQ
Can I measure more than 25 V? Yes, use a larger R1 such as 100 kΩ with 10 kΩ for up to about 55 V, and update the code constants. Stay in a safe low-voltage range.
Can I use a Nano or Pro Mini? Yes. They use the same ATmega328P and the same pins.