Can I use the 5 volt rail as the voltage reference?

Just a beginner question, can I use the 5 volt rail as the external voltage reference on the arduino nano? It seems to be more stable than the internal voltage reference.

or should i just map the exact value like this?

int fiveVolts=4723;
void setup() {
pinMode(A1, INPUT);
Serial.begin(9600);
}
void loop() {
int digitalVal= analogRead(A1);
int analogVal= map(digitalVal,0,1023,0,fiveVolts);
Serial.println(analogVal);

delay(100);
}

If by "5 volt rail" you mean the voltage on the Arduino 5v pin then that is the default used by analogRead().

What Arduino are you using?

...R

The internal 1.1V voltage reference is more stable, why not use that?

When i convert the readings i get 0-1023 to 0-5 volts by mapping like this

int analogVal= map(digitalVal,0,1023,0,5000);

i get inaccuate results by like 200-300 milivolts so is it ok if I measure the 5v rail accurately and devide by that?

Yes, if the ADC uses the default analog reference you should use the actual measured value of Vcc in the equation.

szevlin:
Just a beginner question, can I use the 5 volt rail as the external voltage reference on the arduino nano? It seems to be more stable than the internal voltage reference.

The 5volt supply is already used as reference by default.
You won't have to do anything for that.

Which sensor you are using.
Many sensors (pots) are ratiometric. Absolute voltage does not matter, and default is the most stable setting.
But if you want to measure 'voltage', you need a stable reference. The Nano has a built-in 1.1volt Aref for that.
Study ratiometric vs absolute measurements.
Leo..

It is a small difference, likely not at the root of your problem, but the correct scaling factor is 1024 not 1023.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.