Go Down

Topic: DC Voltmeter {HELP!} (Read 87 times) previous topic - next topic


Good afternoon all,

So I want to make a voltmeter using Arduino UNO. whenever i use the internal voltage source (The 5V and 3.3V ) it gives me a kind of correct answer but whenever i use an external voltage source, ie a battery or a dc generator it gives me the max analog value (1023).

I am using a voltage divider with R1= 100Kohm and R2= 10Kohm

Here is the code.

int analogInput = A0;
int value = 0;
float R1=100000.0;
float R2=10000.0;
float R3=5.0;
float vin=0.0;
float vout=0.0;
float current=0.0;

void setup(){
   pinMode(analogInput, INPUT);
void loop(){
   value = analogRead(analogInput);
   vin= value*5.0/1023.0;
   vout= vin/(R2/(R1+R2));
   current = vout/R3;


Please post schematic of your circuit (real schematic, not Fritzy wire diagram - hand drawn is fine). Most likely there's an error in your wiring.
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.


Thank you sir! I have figured it out! I didn't connect the R2 to the Arduino's GND...

Go Up