Remaining Battery Life

I have an imp connected to 4xAA batteries. Is it possible to monitor how much battery is left?

I want the agent code to send me an email when battery life drops to around 30%… neat.

Since you don’t want to read voltages that are higher than 3.3V with the imp, you need to build a voltage divider that will allow you to read a fraction of that voltage. It is also helpful to be able to turn that circuit on and off so that the resistors aren’t constantly drawing current. Many of the reference designs have this circuit, including Vanessa. That isn’t going to actually give you remaining battery life, but if you know how the voltage drops off for a given type of battery, you could get a good idea. Every battery type is going to respond a little differently.

Simple cheat: tap off the voltage of the first battery and monitor it. If you always use the same type of battery in all four and replace them at the same time (and why wouldn’t you) then this always gives you a quarter of the full voltage. The alarm voltage depends whether you are using alkanine, lithium etc, different chemistry gives different discharge curves. None of them behave as nicely as lipo.

For a low low alarm you could monitor hardware.voltage (), when that droops below 3.3 you know your batteries will die very soon, get an sos message out quick!