Bettery level with battery shield

Is it possible to programmatically find out the charge level of the battery with the battery shield?

Nope, you’ve got two options here:

  1. Use a resistor divider to bring 4.2V down to 3.3V and hook that into one of the analog inputs, then just use the ADC to measure the voltage. Now, due to the fact that lithium batteries don’t discharge over a linear curve like other battery types, this won’t be very accurate. (For example, the battery will normally discharge quickly to around 3.7V, then stay there for a length of time before dropping off to 3.3V and curving downward.) This is good enough for a rough status, or if you want to shut the thing down or send a warning when it’s almost out of juice. But, if you want an accurate measure of capacity you’ll need a…

  2. Li-Ion Battery Gauge! There are tons of these on the market, with the most accurate being from TI and Maxim. Most interface over I2C, but Maxim has some 1-Wire units as well (which would pair well with the hardware 1-Wire Library another user wrote for the Core). These battery gauges use various methods to measure voltage and current flow out of the battery, including high and low side shunts. Ultimately these gauges count individual coulombs to keep track of the total charge in the battery.

Here’s a LiPo Fuel Gauge from SparkFun that I’ve used and works pretty good!

Here’s a list of Battery Gauge products from TI. They’ll normally ship you a free sample overnight. (You can get them in SOIC format, so if you have a SOIC-to-DIP adapter it’s easy to setup.)

2 Likes

Good info Tim! I’ve been thinking of this question as well and a way to shut down my core completely to keep my lipo from discharging below 3V. I was thinking a p-channel mosfet between the battery and the core’s Vin might be a good way. Two resistors between the gate and a digital output on the core. A momentary switch pulls the center tapped point to ground (on switch), and the core can power up and set the digital output low. Once that happens you’re good to let go of the switch. The gate is also pulled up to the source with another resistor. To turn it off, set the digital output to a digital input (high impedance) and let nature take it’s course.

The core might brown out before this gets a chance to happen though, not sure… but you still need the mosfet in-between to keep the battery from further draining. Would make a nice part of a battery backpack… but I’d almost rather have the 3V shut off done in hardware… or maybe at least a slightly lower hardware limit to allow the software to shut down gracefully … but have a backup hardware shutdown in case the software is hung.

1 Like

Wow, thanks for the detailed response! The LiPo Fuel Gauge looks excellent!

1 Like

Time to dig up an old thread!

As my battery testing gets closer to being finished, I’m finally getting close to actually building my solar weather sensor. I was thinking that my next phase would be to do some real-world tests using the solar panel and its charge rate in various conditions (black-out thunderstorm, beautifully sunny, etc), but my coworker asked if I could dynamically adjust my sleep intervals based on battery charge level and estimated battery life left. That’s where this thread comes up!

I currently have:

Could I use the LiPo Fuel Gauge mentioned above to monitor battery levels? If so, where would it best fit in my project? Between the battery and the charger? Between the charger and the Spark?