Close

Voltage measurement

A project log for Lab bench Supply

Build a simple power supply for diy projects

csiszr-attilaCsiszár Attila 10/21/2017 at 19:350 Comments

So I digged the internet about measuring the voltage with an Arduino.

I found this article as the most informative one: http://www.skillbank.co.uk/arduino/measure.htm

The most important thing is that Arduino's analog chips can measure voltage, and convert it to a value between 0 and 1023. But the analog pins cannot handle more than 5V, so I have to use a simple voltage divider to chop off the above 5V parts of the voltage. Testing the circuit on a breadboard the measuring kind of worked, but the accuracy was not the best. 

The problem is that the arduino's atmel chip has an internal voltage reference which depends on the power supply. So you cannot rely on that its a constant 5V hence the measurement won't be accurate.

To avoid this problem the atmel chips has an option - the AREF pin - to supply an external reference voltage to the analog converter.

So I went throught the options, an bought an MCP1541 voltage reference IC. 

By the way, It has a fantastic data sheet. Full of examples and detailed instructions about how to design a circuit around this chip. The key is you have to put a at least an 1uF capacitor between the Reference Out pin and Ground.

So I hooked it up with and Arduino, and with this code I checked that it working quite accurately - I correlated datas with my multimeter.

int voltageMeasurePin = A2;
float referenceVoltage = 4.108;
int analogVoltage = 0;
float measuredVoltage = 0;
void setup() {
  analogReference(EXTERNAL);
  Serial.begin(9600);
}
void loop() {
  analogVoltage = analogRead(voltageMeasurePin);
  float measuredVoltage = (referenceVoltage / 1024) * analogVoltage;
  Serial.print("A: ");
  Serial.print(analogVoltage);
  Serial.print("   ");
  Serial.print(measuredVoltage);
  Serial.println(" V");
  delay(1000);
}

Discussions