Skip to content

[Feature] Implement full battery charge estimation #73

Description

@RomanAlexandroff

Description

Generally, an ESP32 is natively able to measure the full scale of its battery voltage. Unfortunately, in case of the Seeed Studio XIAO ESP32-C3 boards (used in this project), ESP32-C3 cannot do it because there is an LDO between it and the battery. The LDO limits the voltage to 3.3V, so, while the battery voltage is higher or equal to 3.3V, the ESP32-C3 "sees" only those 3.3 volts. The ESP32-C3 starts "seeing" the actual battery voltage only after it goes below 3.3V. Such a low voltage indicates that the battery has a very low charge left.

Currently, the device can detect that the battery is getting low by measuring the ESP32's VCC voltage once the battery voltage falls below the LDO's regulation range. This allows us to detect the low-battery range, but it does not provide any useful information about the battery charge level while the battery is within the normal regulated voltage range.

Implement a software-based battery charge estimator capable of providing an approximate charge level across the full usable battery range, from 100% to 0%, without requiring additional hardware.

The solution should:

  • Work without a battery-voltage sensing circuit or other hardware modifications.
  • Have as little impact as possible on the device's power-saving behavior and Deep Sleep operation.
  • Estimate battery charge primarily from the device's own power-consumption history.
  • Make use of VCC measurements in the LDO dropout region as a reliable low-battery reference.
  • Detect charging and completed charging where possible using information already available to the ESP32 (including temperature).
  • Account for battery aging and gradually adapt the estimated effective capacity over time.
  • Avoid requiring manual characterization or calibration of each individual battery; the only battery-specific value expected from the user should ideally be its nominal capacity in mAh.

The detailed design, investigated approaches, constraints, and open questions are documented in the attached Software-Only Battery State Estimator for Seeed Studio XIAO ESP32-C3.md document.

Acceptance Criteria

  • The firmware can report an approximate battery charge level across the full usable range.
  • The estimator does not require additional hardware.
  • Normal Deep Sleep behavior is not significantly affected.
  • Battery consumption caused solely by the estimator is negligible.
  • The estimator can recognize and use charging/full-charge events when possible.
  • The estimator can adapt its effective battery capacity as the battery ages.
  • The estimator gracefully handles uncertainty and does not make abrupt, unjustified percentage changes unless supported by strong evidence.
  • The implementation and underlying estimation model are documented.

Related Documentation

See the attached Software-Only Battery State Estimator for Seeed Studio XIAO ESP32-C3.md document for the detailed design and research notes.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions