Digital Voltmeter with Arduino

Arduino Project: Digital Voltmeter with LCD

Difficulty Level: Intermediate

Create a digital voltmeter using an Arduino and a 16x2 LCD. This project demonstrates how to measure voltage (0V to 5V) and display it in real time on an LCD screen.

Required Components

Wiring Diagram

The LCD connects to the Arduino via the I2C interface:

The voltage to measure should be connected to analog pin A0.

Code Explanation

The code reads an analog input using the Arduino’s ADC (Analog-to-Digital Converter), converts it to a voltage, and displays it on the LCD.

Key Concepts

Arduino Code

Use the following code to build your voltmeter:


// Include libraries for I2C LCD
#include 
#include 

// Initialize the LCD with I2C address 0x27
LiquidCrystal_I2C lcd(0x27, 16, 2);

int analogPin = A0;  // Pin to measure voltage
float inputVoltage = 0.0;  // Variable for voltage value

void setup() {
  lcd.begin();              // Initialize LCD
  lcd.backlight();          // Turn on backlight
  lcd.print("Digital Voltmeter");
  delay(2000);              // Display welcome message for 2 seconds
  lcd.clear();
}

void loop() {
  int sensorValue = analogRead(analogPin);  // Read analog input
  inputVoltage = sensorValue * (5.0 / 1023.0);  // Convert ADC value to voltage
  
  lcd.setCursor(0, 0);       // Set cursor to first row
  lcd.print("Voltage: ");    // Display label
  lcd.print(inputVoltage);   // Display measured voltage
  lcd.print(" V");           // Append "V" for volts

  delay(1000);               // Update every second
}
            

How It Works

Upload and Test

  1. Connect the Arduino to your PC using a USB cable.
  2. Open the Arduino IDE and paste the code above into the editor.
  3. Install the LiquidCrystal_I2C library via the Arduino Library Manager if not already installed.
  4. Select your board and the correct port in the IDE.
  5. Click the upload button to program the Arduino.
  6. Adjust the input voltage and observe the changes on the LCD screen.

Tips for Customization

Conclusion

This digital voltmeter project demonstrates how to measure and display voltage using an Arduino and an LCD. It’s an excellent starting point for learning ADC, I2C communication, and voltage measurement. With minor modifications, this project can be adapted for a variety of applications.