In this article, we are going to measure high voltage using Arduino. Measuring over 1500V is not safe to work at all. But sometimes, we need to implement such a meter. Here in this article, we will make a high voltage DC voltmeter with Arduino UNO that can measure over 1500V. As assistive devices, we’ll use Op-Amp and 4×1 seven segment display. Let’s start our High voltage DC measurement using Arduino.

Disclaimer:

Advertisements

High voltage measurement technique:

Measuring high voltage is not safe for anyone. But if it needs to be done, then we must find a safe way to do the job. We should not measure high voltages keeping one terminal connected with the measuring instrument. Connecting with a common terminal increases the risk of getting an electric shock, burn, or fire.

That is why isolation is required. Sometimes this isolation is done through high-valued resistors, sometimes with optocouplers. But in the DC circuit, we can use high-valued resistors in series to form isolation. Adding an Op-Amp circuit, the process becomes more sensitive and accurate.

Op-Amp based high voltage measurement circuit:

Op-Amp based high voltage measurement

Here in this circuit, we use an Op-Amp and several resistors to make a floating or isolated voltage measuring circuit. The circuit simply measuring the voltage difference between two points. This differential amplifier circuit can be used in many types of measuring circuits where we can measure the voltage differences of two points. Simple configuration and simple calculation.

Here, Gain = R9/(R2+R6+R7+R8)

Voltmeter circuit diagram:

Utilizing the differential amplifier circuit we can draw our circuit diagram of the voltmeter.

Circuit diagram

Arduino Coding:

Before we start coding, I’m requesting you to check my other article about “DC voltage measurement with Arduino and Multiplexed 7Segment display“.

#include <TimerOne.h>
const char segment_pins[] = {13, 12, 11, 10, 9, 8, 7, 6}; //segments a to g
const char digit_pins[] = {5, 4, 3, 2}; // 4digits
const int digit_number = 4;//for 4 digit segment
byte dot_position;//set dot position from right side.
bool dot_point = false; // having dot or not, true = have dot, false = no dot.

const int segment_array[10][8] = // for common cathode segment only
{
  {HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, LOW, LOW}, //0
  {LOW, HIGH, HIGH, LOW, LOW, LOW, LOW, LOW},     //1
  {HIGH, HIGH, LOW, HIGH, HIGH, LOW, HIGH, LOW},  //2
  {HIGH, HIGH, HIGH, HIGH, LOW, LOW, HIGH, LOW},  //3
  {LOW, HIGH, HIGH, LOW, LOW, HIGH, HIGH, LOW},   //4
  {HIGH, LOW, HIGH, HIGH, LOW, HIGH, HIGH, LOW},  //5
  {HIGH, LOW, HIGH, HIGH, HIGH, HIGH, HIGH, LOW}, //6
  {HIGH, HIGH, HIGH, LOW, LOW, LOW, LOW, LOW},    //7
  {HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, LOW},//8
  {HIGH, HIGH, HIGH, HIGH, LOW, HIGH, HIGH, LOW}, //9
};


void int_sev_segment()
{
  for (int k = 0; k < 8; k++)
  {
    pinMode(segment_pins[k], OUTPUT);//I/O settings
  }
  for (int k = 0; k < digit_number; k++)
  {
    pinMode(digit_pins[k], OUTPUT);//I/O settings
  }
  for (int k = 0; k < 8; k++)
  {
    digitalWrite(segment_pins[k], LOW);//keep low
  }
  for (int k = 0; k < digit_number; k++)
  {
    digitalWrite(digit_pins[k], HIGH);//keep high = disable segments (CC)
  }
  Timer1.initialize(5000);//5000us = 5ms
  Timer1.attachInterrupt(display_segment);
}


char digits[5];
void display_7segment(int number, byte dot)
{
  digits[3] = number / 1000u;//extract 1000th digit
  digits[2] = (number / 100u) % 10u;//extract 100th digit
  digits[1] = (number / 10u) % 10u;//extract 10th digit
  digits[0] = (number / 1u) % 10u;//extract 1st digit
  dot_position = dot;
}


int digit_position = 0;
void display_segment(void) // called periodically using timer interrupt
{
  for (int k = 0; k < digit_number; k++)
  {
    digitalWrite(digit_pins[k], HIGH);//reset digit pins
  }
  if (digit_position > 3)digit_position = 0;

  for (int k = 0; k < 8; k++) //print the a to g segment pins
  {
    digitalWrite(segment_pins[k], segment_array[digits[digit_position]][k]);
    if (digit_position == dot_position && dot_point == true)
    {
      digitalWrite(segment_pins[7], HIGH);//print dot point
    }
  }

  if (digit_position == 3)
  {
    digitalWrite(digit_pins[0], LOW);
    digitalWrite(digit_pins[1], HIGH);
    digitalWrite(digit_pins[2], HIGH);
    digitalWrite(digit_pins[3], HIGH);
  }
  else if (digit_position == 2)
  {
    digitalWrite(digit_pins[0], HIGH);
    digitalWrite(digit_pins[1], LOW);
    digitalWrite(digit_pins[2], HIGH);
    digitalWrite(digit_pins[3], HIGH);
  }
  else if (digit_position == 1)
  {
    digitalWrite(digit_pins[0], HIGH);
    digitalWrite(digit_pins[1], HIGH);
    digitalWrite(digit_pins[2], LOW);
    digitalWrite(digit_pins[3], HIGH);
  }
  else if (digit_position == 0)
  {
    digitalWrite(digit_pins[0], HIGH);
    digitalWrite(digit_pins[1], HIGH);
    digitalWrite(digit_pins[2], HIGH);
    digitalWrite(digit_pins[3], LOW);
  }
  digit_position++; 
}


long dc_voltage = 0;
void setup()
{
  int_sev_segment();//initialize seven segment program
}

void loop()
{
  dc_voltage = 0; //clear previous result
  for (int i = 0; i < 20; i++)
  {
    dc_voltage += analogRead(A0)*1.472; 
  }
  dc_voltage /= 20; //get average value

  display_7segment(dc_voltage, 0); //display value of cnt, dot in position 1 from right side

}

// end

Here all the codes are almost the same as in my previous articles. Only the constant 1.472 is calculated from different values.

Tips: In most of the circuits, calculations are linear. Here you can simply calculate the value of the constant by maximizing the input range and then checking the maximum ADC reading. Then simply calculate the constant.

Const. = Maximum Input/ Maximum ADC reading.

Test result:

The test result of our High voltage DC measurement using Arduino project in proteus:

Test result

As you can see we can easily measure 1500V with our Arduino-based DC voltmeter. If you need to measure higher voltage, you can add resistance in series in the input lines of the op-amp.

But keep in mind that electricity is always dangerous. Do work at your own risk.

I hope you have learned how to make a high voltage DC voltmeter using Arduino UNO and Op-Amp circuitry. Now you can make one for yourself. If you need any help, just ask me. Thank you. Enjoy!

For Professional Designs or Help:

Loading

Check this out: 5 coolest multimeters you can buy


MKDas

Mithun K. Das. B.Sc. in Electrical and Electronic Engineering (EEE) from KUET. Senior Embedded Systems Designer at a leading international company. Welcome to my personal blog! I share articles on various electronics topics, breaking them down into simple and easy-to-understand explanations, especially for beginners. My goal is to make learning electronics accessible and enjoyable for everyone. If you have any questions or need further assistance, feel free to reach out through the Contact Us page. Thank you for visiting, and happy learning!

14 Comments

djalltra · 20/10/2020 at 11:18 am

thanks a lot I’ll try to port the code using mikroc

Alex · 18/10/2021 at 1:16 am

Hello
Very good project
Can you help to my questions??
The pin 7 to opamp connect to ground??
The capacitor is electrolytic?
The rv1 is variable resistor??
The resistors how many watts??

    MKDas · 18/10/2021 at 1:39 pm

    Thanks.
    GND
    Electrolytic
    Variable resistor
    0.25W

subhajit bera · 15/10/2022 at 11:22 am

what is the value of rv1?

Guidus · 10/05/2023 at 3:00 pm

Hello,
What happens if the polarity is reversed at the measurement?

    MKDas · 10/05/2023 at 8:14 pm

    You will not get right reading.

      Guidus · 11/05/2023 at 12:21 pm

      Thanks for your response.
      But the circuit and the arduino are protected in case of wrong polarity ?

        MKDas · 11/05/2023 at 12:56 pm

        If you invert only the sensing points of the HV source of the measurement circuit, Arduino will be ok, you will just get wrong values.

Zubair · 03/01/2024 at 7:38 pm

Hello sir, can i use tl081 instead of opa350pa or other alternatives?

trilok · 11/06/2024 at 10:13 am

dear sir,
i want to implement this setup for shunt monitoring i have few doubts:-
1. i am using esp 32 s3 as mcu the gpio can handle 3.3v so what momdification should need to be done to step down 4.9v to 3.3v?
2.what is accuracy % of measurement?
3.what is calibration factor iam not aware of this can you explain?
4.there is any circuit for low side and highside current measurement?
waiting for your valuable insights!

    MKDas · 11/06/2024 at 8:52 pm

    1>> use resistor voltage divider
    2>> depends on tolerance of the parts
    3>> calibration is the adjusting value of all calculations
    4>> maybe

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *