user57281: I'm trying to read voltage using Arduino, here's the code:
float r1 = 99700;
float r2 = 10004;
float adc, voltage;
unsigned long analog;
void setup() {
  Serial.begin(9600);
  analogReference(EXTERNAL);
  pinMode(A0, INPUT);
}

void loop() {
  for (int i = 0; i < 64; ++i) {
    analog += analogRead(A0);
    delay(1);
  }
  analog = analog / 64;
  adc = (analog * 2.441) / 1024;
  voltage = adc / (r2 / (r1 + r2));
  Serial.print(analog);
  Serial.print(", ");
  Serial.print(adc);
  Serial.print(", ");
  Serial.print(voltage);
  Serial.println(" ");
}

Had a VERY noisy reading and what I did was adding an external voltage reference (TL431) and also connected a 9V switching adapter to Arduino UNO. But I still had some noise in analog readings so as you can see in the code I'm taking 64 sample and averaging them.
After doing all those noise reduced a lot but not completely:
 
What else should one do to get an steady reading?
By taking 1024 sample noise will be removed but then I'm sacrificing performance...

user57281: I solved the problem by adding 3 capacitors:

220uF on the Arduino power supply.
100uF on TL431 output.
1uF on A0 input.

I also increased the sampling rate to 128 times (and removed the delay).
Here's the result, as accurate as my multimeter:


There's still 2mV difference in higher voltages which is because of my 2.5V reference voltage and Arduino ADC 10bit resolution (2.5 / 1024 = 0.002).

57281: <p>I'm trying to read voltage using Arduino, here's the code:</p>

<pre><code>float r1 = 99700;
float r2 = 10004;
float adc, voltage;
unsigned long analog;
void setup() {
  Serial.begin(9600);
  analogReference(EXTERNAL);
  pinMode(A0, INPUT);
}

void loop() {
  for (int i = 0; i &lt; 64; ++i) {
    analog += analogRead(A0);
    delay(1);
  }
  analog = analog / 64;
  adc = (analog * 2.441) / 1024;
  voltage = adc / (r2 / (r1 + r2));
  Serial.print(analog);
  Serial.print(", ");
  Serial.print(adc);
  Serial.print(", ");
  Serial.print(voltage);
  Serial.println(" ");
}
</code></pre>

<p>Had a VERY noisy reading and what I did was adding an external voltage reference (TL431) and also connected a 9V switching adapter to Arduino UNO. But I still had some noise in analog readings so as you can see in the code I'm taking 64 sample and averaging them.</p>

<p>After doing all those noise reduced a lot but not completely:</p>

<p><a href="https://i.stack.imgur.com/UgykZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UgykZ.png" alt="console"></a> </p>

<p>What else should one do to get an steady reading?</p>

<p><sub><em>By taking 1024 sample noise will be removed but then I'm sacrificing performance...</em></sub></p>
 57281: <p>I solved the problem by adding 3 capacitors:</p>

<ol>
<li><p>220uF on the Arduino power supply.</p></li>
<li><p>100uF on TL431 output.</p></li>
<li><p>1uF on A0 input.</p></li>
</ol>

<p>I also increased the sampling rate to 128 times (and removed the delay).</p>

<p>Here's the result, as accurate as my multimeter:</p>

<p><a href="https://i.stack.imgur.com/yy4p4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yy4p4.png" alt="concole"></a></p>

<p><a href="https://i.stack.imgur.com/lSvgw.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lSvgw.jpg" alt="result"></a></p>

<p>There's still 2mV difference in higher voltages which is because of my 2.5V reference voltage and Arduino ADC 10bit resolution (2.5 / 1024 = 0.002).</p>
