I am working on a project that uses a LiPo 3S (11.1v Nominal, ~12.4 full). I want to keep track of battery percentage left. Can I put a resistor on the positive of the battery so i get a 0-5 v reading, and use Ohm's law to measure the battery life left through an analog pin(and what current will it draw)? Will this cause a short?
You need a resistor divider (a pair of resistors) to ensure the highest possible battery voltage does not present more than 5v aat the ADC pin. For example a 10k and a 4.7k resistor would reduce 13v to just over 4v.
battery ---- 10k -----4.7k------ GND
|
analog pin
Bear in mind that this resistor divider will waste close to 1 mA from the battery.
You should experiment to see what actual readings you get at the different stages of battery discharge to give confidence in the results.
You should experiment to see what actual readings you get at the different stages of battery discharge to give confidence in the results.
AFIK reading the voltage doesn't give you a very accurate indication of remaining capacity, because the voltage remains fairly constant as Lipo's are discharged.
Also AFIK systems that use Lipos, normally monitor the current being drawn and calculate capacity remaining.
Voltage can give you a decent idea of the mW remaining, but only when the battery is not under load (the more amperage you draw, the more voltage temporarily dips). The no-load discharge curve isn't linear, but this can be compensated for in software easily enough. And if your battery experiences a fixed and known load (i.e., the Arduino is the one switching the load on/off, or you can use an input pin to sense when the load is applied), you can compensate for the loaded-voltage-drop in software.
For complex/variable loads, a Coulomb Counter, as rogerClark suggested, is the preferred method -- assuming you know the mWh capacity of your battery ahead of time, and assuming you start with a fully charged battery. You would probably still want to sense voltage before any load is placed on the battery to get an idea of the initial state of charge, then proceed with the Coulomb Counter from there.
As for the OP's question, a resistor voltage divider is a fine solution for sensing voltage (other considerations aside). It does "waste" some power, but selecting high resistor values will minimize the waste. I don't have experience personally, but the analog input pins have about 10K? 100M? of impedance, so I imagine a few uA through your resistor divider should be acceptable?
The analog input pins have at least 100 Megohms input impedance, so the current draw is utterly negligible. They do have an associated capacitor and for that to be rapidly charged the impedance of the divider is supposed to be 10K ohms or less. However, for very low frequency voltage changes like battery voltage monitoring, 1 Megohm divider impedance is OK.
So, for voltage monitoring, the resistive divider could be 100K and 47K, or even 1Meg and 470K to reduce the "wasted" power.
tylernt:
Oops I just Googled to get that 10K?, which is obviously wrong, sorry.
Not completely wrong, actually. The ADC requires the load to have an output impedance (hope I have that correct) of about 10K - for example one would use a 10k potentiometer (if one was using a pot). So I think you do need a 10k voltage divider.
The divider input impedance needs to be 10K ohms or less ONLY if rapidly changing voltages are to be measured. I've been using 1M dividers for years to monitor battery voltage, with no difficulties. Note: you should add a 10 nF capacitor from the divider output to ground, to provide the charge to the input capacitor during the sampling period.
Here is what the (poorly written) ATmega328 data sheet actually states (p. 257):
The ADC is optimized for analog signals with an output impedance of approximately 10 k? or
less. If such a source is used, the sampling time will be negligible. If a source with higher impedance
is used, the sampling time will depend on how long time the source needs to charge the
S/H capacitor, with can vary widely. The user is recommended to only use low impedance
sources with slowly varying signals, since this minimizes the required charge transfer to the S/H
capacitor.