Posts: 82
Joined: Sun Jan 26, 2014 8:09 pm

Battery power / power display in termial

Mon May 21, 2018 2:17 pm


I need to make my raspberry pi zero w portable. I'm only using raspberry lite so i need a battery where its possible to see its charge in the terminal? I would appreciate any recommendations anyone has to offer.

Many thanks.

Posts: 11239
Joined: Wed Jan 25, 2012 6:39 pm

Re: Battery power / power display in termial

Mon May 21, 2018 2:57 pm

The 'Lite' is irrelevant. Without extra hardware there is no way that any model of RPi with any OS and any software can monitor the state of the battery, never mind display it to you.
Quis custodiet ipsos custodes?

Posts: 39
Joined: Thu Jun 09, 2016 6:07 pm

Re: Battery power / power display in termial

Mon May 21, 2018 8:27 pm

drgeoff is right. You would need an i2c voltmeter to act as the battery monitor, and then you would have to derive a voltage to charge mapping, since there is no way to actually measure the charge level of a battery.

Posts: 64
Joined: Sat Jun 01, 2013 7:59 pm

Re: Battery power / power display in termial

Mon May 21, 2018 8:32 pm

To give you more of an idea of what you're in for with a request like this, here are a number of things that you have to understand:

The Raspberry Pi really needs a solid 5V power--no more, no less, because it was designed without the power-management circuitry you get in other computers. Battery-powered pi projects typically use something like a USB battery, which provides a 5V USB power port. I like Anker's batteries for things like this.

To evaluate how much energy is "left" in a battery, typically you measure its output voltage. For a normal alkaline type battery, it has a nominal voltage when full, which slowly drops off at a predictable rate as the battery is drained. Thus, the actually voltage provided at the battery is an indication of how "full" it is.

To provide the solid 5V USB devices need, those battery packs use boost/buck converters to change whatever voltage the actual batteries may be at into the 5V you need. I've tested that with my Ankers, and they're solid--you get a steady 5V clear until the batteries are so drained that the dc/dc converter shuts off. You get a near immediate step down from 5V to 0V at that point, and so there's no way to tell what's left in these batteries from the outside since its output never changes during the drain cycle of the battery.

USB battery packs sometimes have a charge indicator on them. These work by the circuitry inside them. If anyone knows of a design that has a way to tap into that, you may be in luck... but I've never seen one like this.

So you'd be stuck making your own, which would be a cool project! But you'll have to learn about Li-Ion batteries, charging them safely, dc/dc converters, battery monitoring, and what linux needs to determine what's left in the battery. It would likely require some custom circuitry, which would either be piece-meal from pre-made boards (could easily become a bit unwieldy with all the parts you have to connect together), or a custom pcb that you've designed yourself.

The raspberry pi should be considered more like a desktop computer than a laptop computer--it relies on external power, not an internal battery with built-in circuitry to handle the battery capacity and health monitoring that you're used to having in a commercial laptop. You can use batteries for remote operation needs, but as far as the pi is concerned, all power comes from a magic black box with no awareness of what's happening inside of that box.

Return to “General discussion”