Precision voltmeter using ADC

Solving Approach:

const int analogPin = A0;

#define RANGE1 = 0;

#define RANGE2 =1;

#define VCC = 5;

#define VCC_1.1 = 1.1;

#define RES = 1024;

void setup(){

serial.input(9600);

pinMode(A0, INPUT_PULLDOWN);  //check

analogReference(DEFAULT);

}

void loop(){

uint16_t sensorValue = analogRead(analogPin);

float voltage = sensorValue* VCC/1024;

if( voltage < 1.1){

analogReference(INTERNAL);

delay(1000);

sensorValue = analogRead(analogPin);

volatge = sensorValue*VCC_1.1/1024;

}

serialprint("Voltage: ");

serialprint(voltage);

}

 

 

 

Code

/*Paste your code here*/


const int analogPin = A0
#define VCC 5
#define VCC_1.1 1.1
#define RES 1023

void setup(){
serial.begin(9600);
pinMode(A0, INPUT_PULLUP);  //check
analogReference(DEFAULT);
}

float read_voltage(){
	analogReference(DEFAULT);
	uint16_t sensorValue = analogRead(analogPin);
	float voltage = sensorValue* VCC/RES;
	if( voltage < 1.1){
		analogReference(INTERNAL);
		delay(5);
		sensorValue = analogRead(analogPin);
		volatge = sensorValue*VCC_1.1/RES;
	}
}

void loop(){
float v = readVoltage();
serial.print("Voltage: ");
serial.printIn(voltage);
}
 

Output

Video

Add video of output (know more)

 

 

 

 

 

Photo of Output

Add a photo of your hardware showing the output.

 

 

 

 

Upvote
Downvote

Submit Your Solution

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