float get_volt() {
rawVolt = analogRead(voltageSensor);
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 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
-
1Are 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 valuesKIIV– KIIV2020年10月16日 20:51:09 +00:00Commented 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?Aditya Singh– Aditya Singh2020年10月16日 21:08:17 +00:00Commented Oct 16, 2020 at 21:08
-
3Try adding capacitor between GND and A1 first (about 1uF should be fine).KIIV– KIIV2020年10月16日 21:14:41 +00:00Commented Oct 16, 2020 at 21:14
-
1There 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– ocrdu2020年10月16日 22:10:10 +00:00Commented Oct 16, 2020 at 22:10
-
1Does the accuracy improve when you only measure voltage and not current?StarCat– StarCat2020年10月19日 20:07:38 +00:00Commented 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?Tim_Stewart– Tim_Stewart2020年10月16日 23:59:04 +00:00Commented Oct 16, 2020 at 23:59
-
1Very 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– Gil2020年10月17日 01:13:15 +00:00Commented Oct 17, 2020 at 1:13
-
1Thanks 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!Aditya Singh– Aditya Singh2020年10月17日 05:22:22 +00:00Commented Oct 17, 2020 at 5:22
Explore related questions
See similar questions with these tags.