Skip to main content

You are here

Battery Voltage from "bandgap"

7 posts / 0 new
Last post
Battery Voltage from "bandgap"

I am trying to monitor the battery life of a 1S lipo on the jeenode smd, using the concept employed in the radioBlip2.ino sketch.

I have the lipo terminals connected onto the + - terminals next to the BATT label.

Problem is no matter what the battery level is it measures the same value, 3.039V.

I have included the function I use to determine the percentage charge, and the sketch I use to calibrate the bandgap value.

Probably missing something obvious, like a voltage regulator, but I gathered from the the interweb that this would work?

lipo charge.ino1.9 KB
FindAref.ino156 bytes

The vccRead method reads the supply voltage to the ATmega, which is after the regulator. The BATT connection is before that. So yes, you're measuring the regulated voltage. If you want to measure the voltage of the LiPo cell, you'll need to use a voltage divider of some kind, although that will drain the battery quickly---relatively speaking. Look through the forums, I believe there's recently been a lengthy discussion on exactly this subject.

The radioBlip2 sketch is used by @jcw for a tiny node that is fed directly from a single-cell battery, so no regulator in-between.


Good thread to look at.


PS: We are moving today to the Redmine, you remember ? New link for discussions


Ah. Ill have to do it later then.

One last question. Can I determine anything after the voltage regulator? Does it start drooping at some minimum voltage?


Interesting question. The regulator will do its best to maintain a nominal 3.3V (that ~3.0V measured is odd - check the LDO markings). As the input droops, it drives the series pass NPN harder and harder (you can see this futile attempt as wasted current coming out of the 'GND' pin).

This degenerates into Vin - Vdropout (see spec, typically ~200mV) so the measurement will be a valid estimate of the almost exhausted Lipo. The problem with this approach is that coming this far down the discharge curve is not good for the battery and there is considerable hysteresis. Meaning the raw voltage will drop under load (e.g. transmitting a block) and then recover to almost the same level.

Not a bad detection mechanism though - there is probably enough energy left to send out some "replace me now" packets. Best to go into deep sleep at that point, the regulator is continuing to drain the battery to almost total exhaustion.


I am guessing the 3V reading was an inaccuracy in the vccRead calculation. Measuring the Vout on the LDO reads a dead 3.3V.

Does it have degenerate all the way to Vin - Vdropout before we make the decision that the battery needs charging?

Premium Drupal Themes by Adaptivethemes