Monitor battery life for arduino

i know the st products have a battery life monitor. anyone done this to their arduino? and shown on st tile?

I haven’t done it myself, but it certainly can be done. Not sure what specifically you are asking about, though. You’ll need to:

  1. Measure the battery fuel level on the hardware side
  2. Send the value to the hub using the ThingShield library
  3. Add the “Battery” capability to your device type
  4. Add a value tile to show the battery level
  5. Parse the incoming attribute values in the device handler, and update the battery value tile as necessary

The hardest part here is 1, because measuring battery fuel level in hardware is absolutely non-trivial. You can make some assumptions about remaining battery life by measuring the voltage that the battery puts out, but it depends on so many factors (temperature, current draw, chemical composition, battery manufacturer, etc.) It will be very difficult for you to get an accurate reading without considering all those factors.

If you just want a binary (“Good”, “Low”) life monitor, you might get away with a simple voltage divider circuit. Divide the voltage the battery puts out through some appropriately sized resistors and feed it to an analog input on your Arduino. Then, take a look at the battery data sheet. It will often contain a graph showing voltages at different charge states (remaining mAh). Since you know the values of your resistors in your voltage divider circuit, you can easily make assumptions about the voltage put out by the battery at any time.

Lastly, if you are using a LiPo or LiIon battery to power your Arduino you are lucky, because there are dedicated ICs, whose sole purpose in life is to act as a battery fuel gauge. Those are the ICs commonly used in mobile devices (phones, cameras, laptops, etc.). Here is one of those on a handy breakout board: https://www.sparkfun.com/products/10617

thank you so much for the time you took to reply

i think this may be over my head in terms of programming. i wish st made more examples available that would be helpful to buyers of their st shield. would love to see how they made the battery life monitoring possible on the multi-sensor & motion detector.