# Inaccurate and non-precise voltage reading from Arduino Analog pin

``````float get_volt() {
vOUT = (rawVolt * 4.6) / 1024.0;
vIN = vOUT / (R2/(R1+R2));
//if(vIN>12.0){vIN=12;}
//if(vIN<11.12){vIN=11.12;}
//return (vIN - 10.18) * (100 - 0) / (12.0 - 10.18) + 0;
return vIN;
}
``````

I am using a voltage sensor module which has a voltage divider with R1=30K Ohms and R2=7.5K Ohms and can measure up to 0-25V by using 10-bit Analog pin of arduino. the battery voltage comes as 11.4 volts when measured with a multimeter but I am getting an inaccurate reading from arduino ranging from 10.8 to 11.4. the Arduino voltage reference is stable at 4.6 V. Please help me to fix this, you can see the voltage reading in the image PS: the battery and arduino are connected to the same ground.

edit1: adding 0.1uf capacitor helped to improve from this

to this!

the data is taken for over a period of 1 hr at every 5 seconds, its a 12V 4000 mAh battery

• Are you measuring also something else on ADC? Recommended maximum input impedance is 10K, and it looks like yours might be bit weak, so charging sampling capacitor from different levels (= previously measured value) may result in huge differences in measured values
– KIIV
Oct 16, 2020 at 20:51
• nope, I am only measuring the voltage on A1, the current is being measured using A2. So it can be a problem with the uC? Oct 16, 2020 at 21:08
• Try adding capacitor between GND and A1 first (about 1uF should be fine).
– KIIV
Oct 16, 2020 at 21:14
• There is only one ADC in the Arduino, which can be used for several pins. If you are also measuring current inbetween voltage measurements, @KIIV's comment applies; the pins used don't matter. You would have to reduce the voltage divider's impedance, give the ADC more cycles per sample, or measure the voltage twice and discard the first measurement. Oct 16, 2020 at 22:10
• Does the accuracy improve when you only measure voltage and not current? Oct 19, 2020 at 20:07