Simple Arduino Voltmeter

The Most Basic Way to Measure Voltage

Arduino VoltmeterThe Arduino Uno has six analog input pins numbered A0 through A5.

These pins measure voltages from zero to five volts DC.

What gets communicated by the Arduino microprocessor is a measurement that indicates anywhere between 0 and 1023, where:

  • 0 = 0 volts
  • 1023 = 5 volts

This article shows how to make the most basic Arduino voltage measurement.

Connecting your Arduino Voltmeter

Fundamentally all you need to do is connect your Arduino to whatever it is you’re trying to measure. You will do this through your A0 pin and one of your ground pins.  A small battery that is less than 5 volts would be great to connect to for this mini-project.

Simple Arduino Voltmeter Hook UpIMPORTANT NOTE

See that Arduino Ground at the negative side of the battery?  This is perfectly OK.
That said, it is not a good idea to introduce a ground into a circuit if you’re not certain what that ground will do.

The Code

There two notable things going on here.

  1. We’re scaling the digital value that the Arduino communicates as a measurement result.  We divide our “RawValue” by 1023 and multiply it by five.
  2. With the “Serial.println(Voltage,3)” statement, we’re asking the serial monitor to give us a result that shows three digits after the decimal point.

/*
The simplest voltmeter
*/
const int analogIn = A0;

int RawValue= 0;
float Voltage = 0;

void setup(){  
  pinMode(analogIn, INPUT);
  Serial.begin(9600);
}

void loop(){  
  RawValue = analogRead(analogIn); 
  Voltage = (RawValue * 5.0 )/ 1024.0; // scale the ADC  
  Serial.print("Raw Value = " );  // shows pre-scaled value                    
  Serial.print(RawValue);      
  Serial.print("\t Voltage = "); // shows the voltage measured     
  Serial.println(Voltage,5); //3 digits after decimal point  
  delay(500);   // 1/2 sec so your display doesnt't scroll too fast
}

 Accuracy and Precision of the Voltmeter

There are two big things that affect the accuracy of this voltmeter.

  1. When the Arduino provides a result between 0 and 1023, it fundamentally divides that five volteage range of the measurement up into 1023 chunks.  If you were to divide 5 volts up into 1023 chunks, you would find that each chunk is worth 0.00488 volts.In other words, the Arduino is only capable of seeing a change of approximately 5 mV.Said another way, the Arduino analog input has 5 mV of resolution.
  2. The accuracy of the Arduino in this mini-project is very much dependent of the accuracy of the power supply.  In one of  my tests, I used the computer USB cable to provide power and in another case, I used the a nine volt wall wart.

 

Simple Arduino Voltmeter

5 Comments

  1. Manas August 14, 2016
  2. capnfatz@gmail.comAuthor October 24, 2015
  3. capnfatz@gmail.comAuthor October 24, 2015
  4. Wes October 23, 2015
  5. Wes October 23, 2015

Add a Comment

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