LibreSolar / bms-firmware

Firmware for LibreSolar BMS boards based on bq769x0, bq769x2 or ISL94202
https://libre.solar/bms-firmware/
Apache License 2.0
146 stars 67 forks source link

Function `bms_soc_update` no longer called post-zephyr bms driver update #40

Closed pasrom closed 7 months ago

pasrom commented 7 months ago

After the recent Zephyr driver update (commit https://github.com/LibreSolar/bms-firmware/commit/f0ff664c2687e68f9526ed6f4d2f659b1bb0fa19), the bms_soc_update function seems to have stopped being invoked. This has led to the State of Charge (SoC) no longer being calculated. Prior to this update, the function was regularly called at this location: https://github.com/LibreSolar/bms-firmware/blob/39bbaeaf668e310dca520255687771dbc1d52ff8/app/src/bq769x2/bms_bq769x2.c#L154-L162

Could you advise on the best location for invoking bms_soc_update in the current code framework to maintain precise SoC measurements?

pasrom commented 7 months ago

I recommend placing the call to bms_soc_update(&bms) before line 66, where bms_state_machine(&bms) is called. https://github.com/LibreSolar/bms-firmware/blob/f0ff664c2687e68f9526ed6f4d2f659b1bb0fa19/app/src/main.cpp#L61-L66

martinjaeger commented 7 months ago

Thanks for raising the issue. I'm planning to do some further BMS testing tomorrow anyway, so I'll have al look into that.

martinjaeger commented 7 months ago

I agree with your proposed fix and have created a PR (see link above).