Low Battery Monitoring for LiPo

I want to connect a LiPo Battery to a Analog Input on the Arduino, but I'm not sure if I should connect through a resistor or not?

LiPo --> Analog Input
OR
Lipo --> Resistor --> Analog Input

What would all you guys recommend?
What are the Pros and Cons?

If you are talking about less than 5V you can connect it directly, but I recommend using a series resistor and it's not a bad idea to add a capacitor for some filtering. Any resistor from a few K Ohms up to 100K should be good.

What voltage is your Lipo? I use a 2 cell 7,4V Lipo for my Rover/robot, I monitor the battery voltage with a voltage divider consisting of 2 10K resistors.

My LiPo Battery is 3.7v.

And if I add a resistor to it, what calculation would I use to code it to detect the voltage?
And what size filtering cap? 0.1uF?

3.7 is well inside the acceptable range for the analog inputs.

1024 should be 5v and 0 should be 0v - do the math :slight_smile:

You don't need to add a resistor, though it cant harm either.

So I shouldn't add a resistor? or?
What about a filtering cap?

if you are just interested in reading the voltage, you can go ahead and do it (make sure you have common ground) without shorting anything out.

however, if you plan on having it hooked up continuously, you probably want to add a resistor to limit current draw.

Maybe someone with more knowledge wants to chime in? I am not exactly sure how it actually works. just speaking from experience.

It's going to be hooked up permanently, cuz its monitoring its own battery to enter a low power mode as the battery gets low.

So... Yeah... Can anyone share some knowledge with me?

Thanks all for your help! :slight_smile:

well just throw in a resistor. the higher the value, the less current the arduino will draw for monitoring. I dont know how much the arduino would draw without the resistor. I believe its not much. Get out a multimeter and check if you want to know the exact numbers :slight_smile:

fkeel:
well just throw in a resistor. the higher the value, the less current the arduino will draw for monitoring. I dont know how much the arduino would draw without the resistor. I believe its not much. Get out a multimeter and check if you want to know the exact numbers :slight_smile:

Are you proposing to add a series resister to reduce the current drawn through the Aduino's ADC? What would that achieve - it's a high impedance input, isn't it?

The only use I can see for a resister would be as a pair forming a voltage divider to bring a higher voltage into a range the Arduino can measure. The downside of that would be a continuous current leak through the voltage divider - bit of an own goal if you're monitoring the Arduino's own battery.

So would you recommend hooking it up without any resistors or capacitors?

So if I hook it up directly with no components, It should be fine for long-term use, right?

I might consider the series resistor (use 10K -- or whatever you'd like, but 10K is a fine value) just to prevent catastrophe in the event that something bad happens at the analog input. For instance, if it somehow mistakenly gets turned into an output set to LOW, you would have a short to ground. The resistor would limit this to merely a vampiric waste of power. Although, it would do nothing for protection if that input ever turns into a HIGH output. A diode would solve that, but then introduce a voltage drop that you'll have to account for.

A series resistor alone shouldn't influence the measured voltage too greatly. It's not designed as a voltage divider, just limiting current flow. A cap in parallel with the battery (maybe 1-47uF?), as close as possible to the analog input, would help smooth out results in the case where you measure the voltage while something else is making sudden high-current demands. Again, a diode between the battery and the input (before the cap) would ensure those sudden loads can't drain the cap.

In all seriousness, you might just want to consider a dedicated battery monitoring IC. DIY is great and all, but Lithium-based batteries are not as tolerant as other chemistries. There's plenty of opportunity to make a really big mess.

One thing I neglected in my original response was that I assumed you are using a 5V Arduino. If you are using a 3.3V board then don't connect a 3.7V battery directly.

Assuming a 5V Arduino: Connect Battery - to the GND on the board. Connect Battery + to one end of a 10K resistor and the other end of the resistor to the analog input pin. It doesn't have to be 10K, it can be just about anything from a few hundred ohms to a few hundred K ohms. Use the following formula in your code:

Voltage = 5 * Counts / 1023

If you have a 3.3V Arduino then you need to use a voltage divider to reduce the voltage at the ADC Voltage divider - Wikipedia. Connect Battery - to GND on the board and Battery + to 2 resistors in series. The end of the 2 resistors is connected to GND and the middle point is connected to your analog input pin. You want the resistors to be as large as possible because they are going to drain current from the battery. Using two 10K resistors and 3.7V they will draw 185 uA continuously. Depending on the capacity of your battery that could be significant. I recommend resistors between 100K and 500K range. You can calculate what the voltage is at the mid-point using the first formula and the value when you read the analog pin is calculated with the second formula. R1 is assumed to be the resistor between Batt + and the Analog Input and R2 is between the Analog Input and GND:

Voltage(at the pin) = VBatt * R2 / (R1 + R2)
and
ADC Counts = VPin * 1023 / 3.3 <== Replace 3.3 with 5.0 if using 5V system

From those two equations we get the following formula which can be used by your software:

VBatt = (Counts * 3.3 / 1023) * (R1 + R2) / R2 <== Replace 3.3 with 5.0 if using a 5V system

Based on what I've read you probably shouldn't worry about a capacitor. If you have a lot of noise in your system, then adding a capacitor across R2 (from Analog pin to GND) will filter out some of the noise. The formulas for the filter are a little more complicated, so I suggest a 1uF capacitor. If it is still noisy, try 10uF or ask again, telling us your resistor values and how much noise you are getting.

One thing I neglected in my original response was that I assumed you are using a 5V Arduino. If you are using a 3.3V board then don't connect a 3.7V battery directly.

  1. I am using 5V Arduino... The power is going through a boost converter.

Assuming a 5V Arduino: Connect Battery - to the GND on the board. Connect Battery + to one end of a 10K resistor and the other end of the resistor to the analog input pin. It doesn't have to be 10K, it can be just about anything from a few hundred ohms to a few hundred K ohms. Use the following formula in your code:

Voltage = 5 * Counts / 1023

  1. When you say Counts, you mean the reading returned by the Arduino, right?
  2. If I use a 10k Resistor, will there be a voltage drop I have to take into account?
  3. I am also using a external AREF connected directly to the 5v supply line, will I have to change any calculations due to this?

Voltage(at the pin) = VBatt * R2 / (R1 + R2)
and
ADC Counts = VPin * 1023 / 3.3 <== Replace 3.3 with 5.0 if using 5V system

From those two equations we get the following formula which can be used by your software:

VBatt = (Counts * 3.3 / 1023) * (R1 + R2) / R2 <== Replace 3.3 with 5.0 if using a 5V system

  1. Which calculation should I use for 5v Arduino with battery connected to a series 10k Resistor?

Based on what I've read you probably shouldn't worry about a capacitor. If you have a lot of noise in your system, then adding a capacitor across R2 (from Analog pin to GND) will filter out some of the noise. The formulas for the filter are a little more complicated, so I suggest a 1uF capacitor. If it is still noisy, try 10uF or ask again, telling us your resistor values and how much noise you are getting.

  1. I do have a 40mm cooling fan and a 5v servo connected to the system, so would you still recommend the 1uF filtering cap?
  1. When you say Counts, you mean the reading returned by the Arduino, right?

Correct, values are a 10 bit binary result of the analogRead() command and can range from 0 =0vdc input to 1023 = 5vdc input.

  1. If I use a 10k Resistor, will there be a voltage drop I have to take into account?

No there will be no voltage drop due to the very high input resistance of the analog input pin. However there will be possible conversion timing problems with using such a resistor. No resistor is required for wiring the 3.7vdc battery voltage directly to the analog input pin.

  1. I am also using a external AREF connected directly to the 5v supply line, will I have to change any calculations due to this?

Why are you using the AREF pin? By default the arduino uses the Avcc voltage (+5vdc in your case) as the reference already so wiring your 5vdc supply to the AREF pin and using the external reference is redundant and not required.
Lefty

So would you recommend wiring it without a resistor? or with one?

I always thought the AREF was something like 1.1v by default... and I wired it to 5v because I have a couple temp sensors, and some other analog devices hooked up to it... Plus the circuit board is already designed and made, so I have to use what is already existing... Unless I cut the trace, which I'd rather not do... lol

drbogger:
So would you recommend wiring it without a resistor? or with one?

Without one.
I always thought the AREF was something like 1.1v by default...

AREF is a name for a pin that one one can input a voltage to and allow it to be the reference voltage to use with analogRead commands if you set the reference to external. The default is to use the same voltage that is powering the chip, +5vdc in your case. So just leave the Aref pin unconnected.

and I wired it to 5v because I have a couple temp sensors, and some other analog devices hooked up to it... Plus the circuit board is already designed and made, so I have to use what is already existing... Unless I cut the trace, which I'd rather not do... lol

In that case you will have to use the external reference command and set the reference to external. Nothing gained, just redundant in design.
Lefty

Would you recommend the use of a filter capacitor?

I recommend a series resistor, but it is not necessary. There will not be any significant voltage drop. IIRC the input resistance for an analog pin is 10M Ohms. I don't remember if that is typical or minimum, but either way there will be much less than 1uA of leakage current.

You probably won't need a filter capacitor, but if you get a lot of noise in the voltage reading you can add it later. If you have no resistor, then the capacitor won't do much of anything.

SInce you will not have a resistor divider, you should use Vbatt = 5 * Counts / 1023 to convert the analog reading (counts) to battery voltage.