Simple battery level indicator - Page 1
Forum section: electronics / beginners

author: Watth
author_rank: Frequent Contributor
timestamp: December 11, 2021, 11:06:58 am
content: Hey,I'm looking for a way to detect a battery's low charge. It would be a single cell 3.7V LiPo, on a device that works continually as it displays time.Low batt detection doesn't need to be that precise, just an indication that it's on its last quarter or something like that.Is checking the batt voltage sufficient? Does it need to be correlated to the drawn current at the same time ?Thanks for reading.

author: Siwastaja
author_rank: Super Contributor
timestamp: December 11, 2021, 11:35:54 am
content: With li-ion, voltage based battery low indication is widely used and sufficient.Yes, voltage drops under load, especially near empty. You may want to simply filter or smooth the measurement before comparing if the load is peaky. Also, often it's not a problem if the "low battery" indication goes on and off when the cell starts getting empty, as a function of the load. This is intuitive even for laymen. For example, it's been normal that a digital camera shows earlier "low battery" warning when flash is enabled and it's charging, everybody understands this.Finally the required cutoff is defined in the cell datasheet, common values are 2.0V, 2.5V or 2.8V, but this is under significant load. This is the absolute limit for cell lifetime and safety.If your device draws high currents, you may want to set your low battery warning to trig at a lower voltage, such as 3.1-3.2V. On the other hand, if the currents are very small, the cell is empty already at 3.3V so you want to warn at 3.5V.

author: Watth
author_rank: Frequent Contributor
timestamp: December 11, 2021, 11:53:32 am
content: Yes, I will see how the design evolves, and what current is drawn on most demanding times. I'll also check what's the minimum acceptable voltage for involved components.As you said, I think around 3.5 V would be a good threshold.I'm not very knowledgeable with analog circuits.It's not not settled what type of µCU will be used, but let's say it has an internal V reference. If Vref < Vbatt, I guess a simple resistor divider on an analog input of the µCU would do the trick.Anyway, when the time comes I'll ask if someone here would be willing to have a look on what I implement.

author: Siwastaja
author_rank: Super Contributor
timestamp: December 11, 2021, 12:02:30 pm
content: Yes, resistor divider is fine, just remember that if you go into sleep (and turn off all external loads controlled by the MCU) when the battery runs empty, resistor divider current will continue draining the battery.So you must use quite large resistor values. Then you absolutely need the capacitor between A_in and GND to supply the SAR ADC the low impedance it needs (0.1µF MLCC does fine if highest accuracy is not required); and be careful not to trig the ADC conversion too often to drain that capacitor. Once a second is fine anyway.Best to design so that if you cut power when 5% of charge remains in the cell, that 5% is not drained by the quiescent currents if the device sits uncharged on a shelf for a few months.If your MCU can estimate the current draw based on what it is doing, you can change the warning / cutoff limits on the fly. This doesn't need to be rocket science; for example if you are flashing a power LED to take a picture, or sending a large packet over radio, you can reduce the voltage thresholds by 0.2V when starting that and bring it back after a second or two after the job is done. A few lines of code and the solution is already better than what's used in most gadgets on market.

author: Watth
author_rank: Frequent Contributor
timestamp: December 11, 2021, 12:46:54 pm
content: Yup, The battery check would be much less frequent than once every second ! Especially since I will use an RTC I'll be able to program Vbatt checks less often but with regularity (i.e. no risk It would "forget" to check).I'm thinking of adding a way to measure the battery current, like a 0.5mohm R, is that overkill? I'm not expecting more than 250 ma peak current. And when the device is idling, really 5mA at most.

author: Siwastaja
author_rank: Super Contributor
timestamp: December 11, 2021, 01:11:11 pm
content: Current measurement enables interesting things like Coulomb counting but for the usual gadget, there is no need. Those overkill solutions have risk of backfiring, for example Coulomb counting can show colossally wrong numbers unless the current sense is very accurate (like < 1% error), algorithms are very complex, or the usage pattern hides the problems by luck (i.e., users always fully charge the device between each use). Thousands of competiting special ICs exist to do that, I don't have much confidence in them but I roll my own, but that takes obviously more effort.Voltage based is always in the right ballpark, and simple. It can be simply improved by trivial ad-hoc additions when need arises, like filtration or moving thresholds.Unless there is some other reason to measure the current, I wouldn't bother. You can always measure the current in the prototype to see how much each action consumes. This is good development practice anyway.

author: rpiloverbd
author_rank: Regular Contributor
timestamp: December 12, 2021, 10:20:54 am
content: Will you use it on a microcontroller based project? Then I think adding a bar graph module will help.

author: Watth
author_rank: Frequent Contributor
timestamp: December 12, 2021, 01:25:24 pm
content: Quote from: rpiloverbd on December 12, 2021, 10:20:54 amThere is a display involved that will indeed display when the battery gets to a low level.

author: Peabody
author_rank: Super Contributor
timestamp: December 12, 2021, 03:54:02 pm
content: Here's a circuit I ran across that lets you switch on a voltage divider to take a reading, then turn it off. I assume this could be done very rapidly, so there would be no meaningful current usage.

author: Siwastaja
author_rank: Super Contributor
timestamp: December 12, 2021, 04:12:17 pm
content: Yeah, I have even used the GPIO pin itself to disconnect the divider network (i.e., instead of GND, use a GPIO, and drive it either to GND or leave hi-z) but that requires the raw measured signal to sit between Vcc and GND so that no current flows through protection diodes. With external FET, you don't have that limitation. I found out that the GPIO pin DC resistance is surprisingly non-linear and this required calibration.Remember the capacitor though for correct ADC readings, SAR ADC gives interesting effects if source impedance is too high, for example it may first seem just "a bit" off and easily calibrated, but then you add another channel and channel cross-contamination starts.That capacitor also sets the on-time required for the divider network to settle to a stable enough value (at least 6-7 * RC would be a good start).

author: ledtester
author_rank: Super Contributor
timestamp: December 12, 2021, 04:16:28 pm
content: Quote from: Peabody on December 12, 2021, 03:54:02 pmCheck this thread for a discussion on this approach:https://www.eevblog.com/forum/projects/battery-monitoring-voltage-divider/In the end it seems you can just use large resistors and put a small cap on the ADC input. You'll have to reduce the sampling rate as well - but usually not a problem for battery monitoring.

author: Peabody
author_rank: Super Contributor
timestamp: December 12, 2021, 04:36:26 pm
content: I should have added that you probably would want to use a mosfet with a lower Vgs threshold voltage than the 2N7000. With Vcc at 3.3V, the 2N7000 would probably work if you're dividing down to below 1V, but per the datasheet it's only probably. A little SOT23 mosfet with a typical threshold of 1V and a maximum of 1.5V (twice as good as the 2N7000) would be a better choice.