Every lithium-ion battery you use, from a phone to an EV, has a small piece of software and hardware babysitting it. That is the Battery Management System (BMS) . Without one, a pack can overcharge, overheat, or drift out of balance, and the failure modes range from a dead pack to a fire.
In this post I'll cover what a BMS does and then build a minimal BMS core in Rust.
What does a BMS actually do?
A BMS has four main jobs:
Monitoring : it measures the voltage of each cell, the pack current, and temperatures.
State estimation : it estimates State of Charge (SoC, "how full is it?") and State of Health (SoH, "how worn out is it?").
Protection : it opens the contactor or MOSFET when something goes out of range (over-voltage, under-voltage, over-temperature, over-current).
Balancing : cells in series drift apart over time, so it bleeds off the stronger cells to keep the pack even.
The flow in the diagram above is the whole loop: sensors feed the controller, the controller decides, and it acts on the pack…