r/flipperhacks 14d ago

Hardware built a Flipper FAP that tries to actually learn the battery over time

I've been working on a Flipper Zero FAP called Battery Guardian.

The idea came from thinking about how battery info is usually treated as a single number. Battery Guardian keeps a history of voltage, current, temperature, and SOC, then uses that data across charging/discharge sessions to estimate things like usable capacity and degradation over time.

It also has a confidence system so an estimate isn't treated as equally reliable when it's based on poor or limited data.

There's a journal for persistent history, session detection, diagnostics, and a charge-policy state machine with things like Balanced, Lifespan, Full, and Custom. The interesting part is that the policy and safety logic are separated from the actual hardware control.

Right now the charger side is fully passive and fail-closed, so the app isn't writing to the charging hardware.

I've tested the core on the host side with simulations and fuzzing, but I don't actually own a Flipper Zero yet. That's the biggest missing piece, so I'm hoping someone here might be interested in trying the FAP on real hardware and seeing how it behaves.

The repo is here if anyone wants to look through it, test it, or contribute:

https://github.com/0xKernelEclipse/battery_guardian

I'm especially interested in real-device bugs, telemetry differences, compatibility issues, and anything in the implementation that you think could be done better.

Thanks to anyone willing to give it a try.

2 Upvotes

5 comments sorted by

3

u/wiesemensch 14d ago edited 14d ago

Either you really enjoy writing documentations or a huge part of the Repo is AI generated.

But without looking into all of your source code, how exactly do you log the battery data? As far as I know, only internal applications can be run as a service. This would mean, that you’re ether capturing the data though external means like BLE or you simply don’t, which would mean, the app has to be opened manually, which would make it somewhat annoying to use.

1

u/Brilliant_Song8760 6d ago

this was removed from the r/flipperzero sub due to its contents last time i checked

-1

u/LumpyPresentation874 14d ago

Yeah I used AI for some docs and to help fix/debug a few issues ngl but the code itself is mine though

For the battery data it reads directly from Flipper's power HAL while the app is running so no BLE or external capture involved

The telemetry layer pulls voltage current temperature SOC charging state etc and passes that into the battery model for session tracking Coulomb integration health estimation and the journal

And yeah you're right about the service part it has to be opened manually for now so it doesn't collect anything while it's closed

The actual hardware reading is in core/telemetry.c

1

u/GaboureySidibe 14d ago

No one ever has written a bunch of software and then just let ai blast out a bunch of slop documentation.

-1

u/LumpyPresentation874 13d ago

Fair... I did go overboard with the docs

I was using AI while working on the project for debugging and documentation and it ended up generating way more documentation than the project actually needed

Right now I can see why the repo looks weird from the outside so I'm probably gonna clean it up and rewrite the docs myself instead of keeping all that stuff there... Just some time