float get_volt() {
  rawVolt = analogRead(voltageSensor);
  vOUT = (rawVolt * 4.6) / 1024.0;
  vIN = vOUT / (R2/(R1+R2));
  //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.

enter image description here

edit1: adding 0.1uf capacitor helped to improve from this enter image description here

to this! enter image description here

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

  • 1
    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
    Commented 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? Commented Oct 16, 2020 at 21:08
  • 3
    Try adding capacitor between GND and A1 first (about 1uF should be fine).
    – KIIV
    Commented Oct 16, 2020 at 21:14
  • 1
    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.
    – ocrdu
    Commented Oct 16, 2020 at 22:10
  • 1
    Does the accuracy improve when you only measure voltage and not current?
    – StarCat
    Commented Oct 19, 2020 at 20:07

1 Answer 1


This should be a lot of fun but you might consider doing some research on analog circuits and A/D circuits. You have way too many digits to the right of the decimal, the accuracy is not there. The best you can get is 0.0044 volts per count with a 4.6v reference. What are you using to make your measurements, you need at 5 1/2 digit meter to have the decade better accuracy then what you are calibrating to. Your reference you state is 4.6 volts, something is not correct is should be 5.000V. You know any load placed on the on board regulator will have an effect on your A/D readings. The tolerance of the resistors you are using will have an impact on your reading. They generate noise that could be affecting your readings. 100nF should be enough capacitance,this will lower the input impedance. Increasing capacitance beyond this will slow the settling time of the circuit. If you are powering this from a computer USB expect noise from that power source, That would also explain the lower reference voltage on the A/D. With what you indicate you have, you are actually doing very well.

  • Are you saying resistors make noise? I.e packed carbon tubes? Commented Oct 16, 2020 at 23:59
  • 1
    Very definitely as do all other components. At 10 digits to the right of the decimal point it can become a big problem. For more background try this link: allaboutcircuits.com/technical-articles/… This is based on the numbers he printed out. In reality it should not be a problem until you get mayne 14 bits or more depending on the design.
    – Gil
    Commented Oct 17, 2020 at 1:13
  • 1
    Thanks a lot !! adding a 0.1uF capacitor did solve the problem but still there is a noise of 0.1 V, checking out if averaging the readings solves the problem, if you all have any other suggestions please do let me know! Commented Oct 17, 2020 at 5:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.