The problem
Charging lithium-ion cells when they are too cold risks lithium plating, and charging when hot speeds ageing. Vehicle BMS firmware therefore derates or delays charging based on temperature. Choosing the derating rules is a trade-off between charge time, delivered energy and cell stress that should be measured rather than guessed.
Objectives
- Model the effect of temperature on charging limits from the cell datasheet and literature
- Implement a temperature-aware charging policy with start gating, pause and resume, and derated termination voltage
- Compare it against a fixed CC–CV baseline on charge time, delivered charge and a temperature-stress metric
- Validate the policy's limit behaviour with emulated temperature profiles
What you need
From the EV Embedded Development Kit
- Second STM32F103C8T6 as the Smart BMS unit
- 1S battery with connector and T-sense input
- Battery charging unit with its own switch
- Charge/discharge control relay
- BMP280 pressure and temperature sensor
- BMS power switch, OLED and six navigation buttons
- Serial UART interface
- RTC with CR2032 backup cell
Software
- STM32CubeIDE with HAL drivers
- Embedded C
- Python with pandas, NumPy, SciPy and matplotlib
- MATLAB/Simulink (optional, for the thermal model)
Extra parts
- INA219 I2C current and power monitor in the charge path — Charge current is needed for delivered-charge, termination and stress metrics, and the kit does not list current measurement.
This project uses the kit's lithium cell. Respect polarity, never short the terminals, and don't leave the cell charging unattended.
Key concepts
- Lithium plating
- At low temperature, lithium can deposit as metal on the anode during charging instead of entering it, which reduces capacity and can create safety risks.
- Charging temperature window
- Cell datasheets give a narrower allowed temperature range for charging than for discharging; outside it, charging should be stopped or derated.
- Lumped thermal model
- A one-node model in which cell temperature rises with I²R heating and falls with heat loss to ambient, characterised by a thermal resistance and heat capacity.
- Control levers on the kit
- The kit's charging unit sets its own current, so the controller acts by gating when charging starts, pausing with hysteresis and lowering the termination voltage. Current-rate control would need a programmable charger.
Step-by-step guide
- 1
Literature and limits
Review the cell datasheet and published guidance on temperature-dependent charging. Write a table of temperature bands with the allowed action in each: no charging below a cold limit, a reduced termination voltage in cool and warm bands, normal in the middle band and no charging above a hot limit. Identify the control levers available on the kit and state that charge-current derating is out of scope without a programmable charger add-on. Cell safety: check polarity, never short the cell, never heat or cool it artificially and never leave it charging unattended.
Checkpoint: A temperature-band table with sources and a statement of control levers.
- 2
Board setup and sensors
Enable the DIP switches for the battery, charger, relay, BMP280, OLED and UART blocks. Configure the BMS controller at 72 MHz with ADC and DMA for cell voltage and T-sense, I2C for the INA219 and RTC, SPI for the BMP280 as ambient reference, and the relay GPIO default off. Calibrate T-sense against the BMP280 and a thermometer at room temperature after the board has rested.
Checkpoint: Cell and ambient temperatures agree within tolerance at rest, and current reads correctly in both directions.
- 3
Thermal characterisation
Charge the cell under the baseline at room temperature and log cell temperature, ambient temperature and current once a second. Fit a lumped thermal model in Python: estimate thermal resistance and heat capacity from the temperature rise and the time constant. The rise on a small cell at low current will be modest; report it honestly. Repeat the fit on two or three charges to check that the parameters are consistent.
Checkpoint: A fitted thermal model whose predicted temperature tracks the measured curve within a stated RMS error.
- 4
Baseline controller
Implement a fixed CC–CV supervisor: start when voltage and temperature are within absolute limits, terminate at the datasheet voltage and termination current, and stop on timeouts. Log every charge with RTC timestamps. This is the reference against which the new policy is judged. Use exactly the same voltage, current and timeout settings for every baseline run, and record ambient temperature, so the later comparison isolates the effect of the policy rather than differences in conditions.
Checkpoint: Three baseline charges are logged with consistent charge time and delivered mAh.
- 5
Temperature-aware policy
Implement the policy as a state machine on top of the baseline: band classification with hysteresis, start gating, pause and resume when temperature crosses a band edge, and a derated termination voltage in cool and warm bands. Keep relay switching infrequent with minimum on and off times, since relays are not suited to fast cycling. Make every threshold a parameter.
Checkpoint: The policy's state and active band are displayed on the OLED and printed over UART.
- 6
Temperature injection harness
Add a test mode in which the controller uses a temperature profile sent from Python over UART instead of the T-sense reading, while still logging the real reading. Write profiles that cross each band edge, dwell near thresholds and jump suddenly. This tests the policy's limit behaviour without exposing the cell to extreme temperatures. Guard the test mode so it cannot be left on by accident: show a clear indicator on the OLED and time it out.
Checkpoint: Every injected profile produces the expected sequence of band changes, pauses and terminations.
- 7
Simulation study
Combine the thermal model with a simple equivalent-circuit cell model in Python and simulate the baseline and the policy over a range of ambient temperatures. Define a stress metric, such as time spent charging at high voltage weighted by a temperature factor, and compare charge time, delivered charge and stress. Validate the simulator first by reproducing a measured baseline charge, and report its error, before using it to compare policies in conditions you cannot test on hardware.
Checkpoint: Simulated comparison plots for at least five ambient temperatures.
- 8
Hardware comparison runs
Run the baseline and the policy on hardware at room temperature with injected profiles that emulate cool and warm conditions. Use the same starting voltage for each pair, with rest periods between runs. Record charge time, delivered mAh, final voltage and the stress metric. Randomise the order of baseline and policy runs to avoid bias from gradual changes in the cell or room, and keep a run sheet noting anything unusual during each charge.
Checkpoint: Paired results for at least three runs per condition, with mean and spread.
- 9
Analysis and model check
Compare simulation and hardware for the conditions you could test. Quantify the cost of the policy in charge time and delivered charge against the reduction in the stress metric. Discuss whether the stress metric is a reasonable proxy and what longer-term cycling would be needed to show an ageing benefit. Present the trade-off as a curve across threshold settings rather than a single point.
Checkpoint: A results table and a discussion of the trade-off with clearly stated limitations.
- 10
Thesis write-up
Document the literature, the model, the policy, the test harness and the results. Include a section on what cannot be concluded from the kit, such as long-term ageing, and how public datasets or longer cycling would address it. Include the parameter files, scripts and raw logs as appendices or a repository so the comparison can be repeated, and list the cell type, charger settings and firmware version used for every result.
Checkpoint: A complete chapter with reproducible scripts and parameter files.
Testing & validation
- Band transitions and pauses under injected temperature profiles, including hysteresis near thresholds
- Paired baseline and policy runs compared on charge time, delivered charge and stress metric
- Thermal model fit error on measured charges
- Relay switching count kept within the planned limit
Expected results
A temperature-aware charging controller on the Smart BMS unit, a fitted thermal model, an injection test harness, and a quantified comparison with fixed CC–CV charging in simulation and on hardware.
Research angle for your M.Tech thesis
Research questions: how much stress, as measured by a defined proxy, can temperature-aware rules remove for a given increase in charge time, and how robust are the rules to temperature-measurement error? Metrics: charge time, delivered charge, the stress metric, number of relay operations and response to sensor offsets. Baseline: fixed CC–CV with only absolute limits. Model parameters can be cross-checked against public data such as NASA PCoE or CALCE cell tests where temperatures are recorded. A publishable result would combine a validated simple thermal model, a clear stress proxy linked to literature, and a sensitivity study, while being explicit that ageing benefit is not demonstrated on short tests.
Take it further
- Add a programmable-current charger add-on so the policy can also derate current
- Use the BMP280 ambient reading to predict temperature rise before starting
- Optimise thresholds with a multi-objective search in simulation
- Report temperature band and derating as CAN frames to the vehicle
Viva and review questions
Why not test cold charging by putting the cell in a fridge?
Deliberately cooling or heating a lithium cell adds risk and the board is not designed for it. Injecting emulated temperatures tests the control logic safely.
Which levers does your controller have?
Start gating, pause and resume, and the termination voltage. The kit charger fixes its own current, so current derating would need a programmable charger.
Why add hysteresis to the bands?
Without it, a temperature near a threshold would make the relay chatter on and off, which wears the relay and confuses the charge.
What does the stress metric represent?
It weights time at high voltage by a temperature factor taken from literature as a proxy for ageing stress; it is a comparison tool, not a lifetime prediction.