Skip to content

Account for series batteries in the voltage-based SOC estimate - #136

Draft
Solarboaters wants to merge 1 commit into
LibreSolar:mainfrom
Solarboaters:fix/series-battery-soc
Draft

Solarboaters wants to merge 1 commit into
LibreSolar:mainfrom
Solarboaters:fix/series-battery-soc

Conversation

@Solarboaters

@Solarboaters Solarboaters commented Nov 12, 2026 •

Copy link
Copy Markdown

The voltage-based SOC calculation compares total battery-bus voltage with the single-battery OCV limits, even when detect_num_batteries has set series_multiplier to 2. A two-battery bank at the midpoint between empty and full OCV is consequently reported as 100%.

Normalize the measured voltage by series_multiplier before calculating SOC. Added a regression case to the existing battery tests.

An isolated C++ harness executing the production update_soc method reproduced 100% for a two-battery midpoint before the fix and approximately 50% afterward. A single-battery midpoint control also passed. The full Zephyr test suite and hardware testing remain pending.

Audit status (16 November 2026): returned to draft pending actual firmware/test execution. The current GitHub runner fails in setup because apt cannot locate clang-format-15; this occurs before the firmware build and tests. The isolated harness evidence above remains limited to that scope. No successful full CI or hardware test is claimed.

Evidence audit — 17 November 2026

Individually rebuilt and ran the production Zephyr native test image from public revision e58d104e0: 96 tests, zero failures. This is separate from the combined run of #135–#145, which passes all 103 tests. Replacing the relevant production implementations with the original code reproduces the new regression failures.

Reproduction in the west workspace, from the firmware directory:

ZEPHYR_TOOLCHAIN_VARIANT=host west build -b native_sim/native/64 -d ../build tests -- -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DDTC_OVERLAY_FILE=boards/native_sim.overlay
../build/zephyr/zephyr.exe

Environment: Linux x86-64, GCC host toolchain, Zephyr 4.4.2, manifest dependencies. These tests use the project's native simulated interfaces; no ARM board or charging hardware was operated.

The earlier GitHub CI failure was a runner setup failure locating clang-format-15, before source tests ran. The local native result above does not turn that CI run green; board firmware CI remains unverified.

@Solarboaters
Solarboaters marked this pull request as draft November 16, 2026 21:54

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant