Skip to content

[Feature request] Enhancements for battery management #2399

@WhiRav

Description

@WhiRav

Hi, I found 2 issues with battery management and wanted to discuss them (and maybe fix them)

First one:
There are currently 2 flags in UI.cpp:
BATT_MIN_MILLIVOLS - used only to display battery percentage image
AUTO_SHUTDOWN_MILLIVOLTS - used only to automatically power off device
And voltage parameters that may vary across different batteries

Caused problem:
Battery display image is misleading since BATT_MIN_MILLIVOLS usually lower than AUTO_SHUTDOWN_MILLIVOLTS (it may show that battery is 50% full and then shuts down)
Also, both BATT_MAX_MILLIVOLS and BATT_MIN_MILLIVOLS usually are wrong on default flash image since they are hardcoded
Similar problem with percentage display present in MeshCore app, but since flushing custom image with different flags to node didn’t change anything i would assume it uses some sort of db to fetch boundaries for battery

I propose 3 possible solutions:
1 - add #ifdef AUTO_SHUTDOWN_MILLIVOLTS to define BATT_MIN_MILLIVOLTS with it value (did this, works fine)
2 - add behavior so after shutdown device would check if it under AUTO_SHUTDOWN_MILLIVOLTS and would work till BATT_MIN_MILLIVOLTS
3 - initialize battery parameters as variables and let user input them through app after flashing image (since, as I believe, there is no point for AUTO_SHUTDOWN_MILLIVOLTS being that high after flashing image)

Second one:
When node is plugged and charging (or there is any other valid power source for board), but battery level is bellow AUTO_SHUTDOWN_MILLIVOLTS it tries to boot and shuts down (if no battery present it works fine)

Problem is that node current state is affected not by its ability to run, but by charging battery level
Example:
heltec v4 can be powered from solar panel, battery, power cord or pins, but with current way of using AUTO_SHUTDOWN_MILLIVOLTS flag it would boot and immediately power itself off if battery is not charged

My solution:
Modify "if (milliVolts > 0 && milliVolts < AUTO_SHUTDOWN_MILLIVOLTS)" in loop to also check if there is no other valid power source

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions