measure battery voltage

Hy

I like to measure my LiPo battery with my Arduino. The Arduino is running from this battery trough a step up converter:

Arduino---5v Step up---LiPo

where or how do I have to measure the voltage. I always get 4.2V instead of 3.7 what the multimeter tells me...

thx for your help

the good news is you have 5v reference so you can just connect it like this

Arduino analog input----LiPo

or if you want to be conservative

Arduino analog input ---- current limiting resistor ---- LiPo

I've done that but then I just get 4.2V what's wrong compared to to the multimeter...

How are you determining that the analog pin reading corresponds to 4.2 volts? That code may not be quite right.

It is right because when I do connect the Arduino over the USB to the computer (now the Arduino takes the power from the PC) and let the voltage be transmitted over the serial port it does show me the correct one. However when I do disconnect the USB Jack the voltage is completely wrong.

Are you sure your boost converter is working correctly?

When the arduino is connected, try measuring the voltage across the boost converter output.

Mowcius

When connected to USB and when connected to battery, you may be seeing two different Aref values. The value returned by analogRead is a function of Aref. If the formula used to compute voltage assumes that Aref = 5.0, the result will be wrong when Aref != 5.0.

That is why I asked about the code.

Well 4.2 volts is the value of a fully charged Li-Po battery. 3.7vdc is just a nominal rating voltage, and below 3.0 volts is where a Li-po can be damaged from overdischare. Now is the battery really 3.7 or 4.2? Has your multimeter been verifed against an independently known voltage value? What is the actually voltage of your Arduino's +5vdc pin? USB ports are allowed a variation of range around +5vdc and the Arduino on-board +5vdc regulator also has an allowed tolerance value, both of which will effect the 'accuracy' of the A/D value read in software. The true answers is somewhere in that mess. ;)

Recall that man with one watch always knows the time, man with two watches never quite sure.

Lefty

How about using the internal 1.1v ref instead(this way you don’t need to worry about exactly what your supply voltage is) and attaching it as drawn below. The resistors divide the LiPo voltage by 5 so 3.7v would be 0.74v at the analog pin.

the Vlipo=(ADCvalue/1024)1.15

LiPo
|
R=120k
|
±-analog pin
|
R=30K
|
GND

EDIT: whoops i had the resistors backward

Even using the internal 1.1vdc bandgap as the reference voltage there will still be an accuracy variation: From a 328 datasheet:

VBG Bandgap reference voltage VCC=2.7 TA=25°C min-1.0 typical-1.1 max-1.2 V

That's +/- 10% tolerance allowance not even including the resistors tolerance used in the voltage divider. The on-board +5vdc regulator might very well (should be) be better then that!

Instrumentation and accuracy is not a subject with easy answers. One is best guided by first stating what they require in accuracy tolerance, as there is no such thing as perfect measurement accuracy.

Lefty

Note, however that the resistance values shown by mspguy may be a bit high given the input impedance of the Arduino. I would consider scaling them to 1/2 or 1/3 the values shown.

its not so bad, but a fair point. the source resistance is 24k and the datasheet says the ADC is designed for a 10k output impedance. Running the ADC at half the speed would work too. I'm always stingy with power ;) Thats why I'm an MSP430 fan.

If it were me, I'd use whatever two resistors I have around that are close to a 1:4 ratio and give a 10k-100k output impedance, then calibrate it. but I had to choose some numbers for the sake of the forum.

hmm. bummer. The registers could be set manually I guess. probably best to use smaller resistors instead though.

After browsing the datasheet again I saw that at least the mega has a 2.56v ref. That ought to be more accurate (one would hope that they didn't use 3sig figs for something that is +/- 10%) and dividing it with two 20k resistors (or anything matched) might let you avoid calibrating since when you buy the two resistors at the same time they're likely from the same lot and likely to be more matched.

After browsing the datasheet again I saw that at least the mega has a 2.56v ref. That ought to be more accurate (one would hope that they didn't use 3sig figs for something that is +/- 10%)

VINT1 Internal Voltage Reference 1.1V 1.0 1.1 1.2 V VINT2 Internal Voltage Reference 2.56V 2.4 2.56 2.8 V

Nothing to shoot home to mother about. ;)

Lefty

If you're trying to monitor the state of charge of the Lipo battery with the Arduino it's fairly difficult to predict when the battery will be depleted. The discharge profile is relatively flat over the discharge cycle and has a steep drop off near the end. Go out and buy a cordless drill that uses lithium batteries and you'll see what I mean. The drill runs at full power power 99% of the time and then just stops. It doesn't loose power like other battery technologies as it gets closer to completion.

I've been using a MAX17043 to monitor Lipo's and it works like a charm. I'm not sure how your soldering skills are with SMD's, it's a pretty tiny IC. I'm putting together a breakout board for the chip, just waiting for a part to come in. I'll post a link to it some time if I can ever get my website up and running and if you're interested.

How about using the internal 1.1v ref instead(this way you don't need to worry about exactly what your supply voltage is) and attaching it as drawn below. The resistors divide the LiPo voltage by 5 so 3.7v would be 0.74v at the analog pin.

the Vlipo=(ADCvalue/1024)*1.1*5

LiPo | R=120k | +--analog pin | R=30K | GND

hm when I do this I got 0.92V what does that mean?

multiply that number by 4 and that is the battery voltage

why multiply it by 4??? this would be 3.68V but the actual value would be 4.026V

Are those the 10% error?

The resistors have tolerances so they will not be the exact value listed so the divider will not do an exact 1:4 reduction. If you want to know the exact multiplier you would have to measure the resistors with a meter and then do the math.