Precision voltmeter using ADC

Solving Approach:

How do you plan to solve it?

 

 

Code

float vref = 5.0;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
  int analog_read = analogRead(A0);
  if(analog_read == 1023 && vref == 1.1)
  {
    analogReference(DEFAULT);
    vref = 5;
  }
  if(analog_read < 226 && vref == 5)
  {
    analogReference(INTERNAL); 
    vref = 1.1;
  }

  analog_read = analogRead(A0);
  float voltage = (analog_read / 1023.0) * vref;

  Serial.print("Voltage: ");
  Serial.print(voltage);
  Serial.println(" V ");
  delay(100);
}

Output

Video

Add video of output (know more)

 

 

 

 

 

Photo of Output

 

 

 

 

 

Upvote
Downvote

Submit Your Solution

Note: Once submitted, your solution goes public, helping others learn from your approach!