Skip to main content
emobility.academy
B.Tech / BEBattery & BMSIntermediate About 5 weeksKit only

Automated Battery Capacity (Ah) Tester with Data Export

Build an automated tester that charges the kit cell under supervision, rests it, discharges it through the resistive loads to a cut-off and reports measured capacity in mAh and Wh. Each test is timestamped with the RTC and exported over UART as CSV.

Uses: ADC · UART · RTC

The problem

Capacity is the most basic battery specification and the first sign of ageing; EV makers and second-life battery sorters test it routinely. A good capacity test needs a controlled sequence, a reliable cut-off, accurate timing and clean records. This project builds a small automated tester and teaches why test procedure matters as much as the measurement.

Objectives

  • Sequence charge, rest, discharge and rest steps automatically.
  • Estimate discharge current from measured voltage and calibrated load resistance and integrate it into mAh and Wh.
  • Stop discharge at a defined cut-off voltage and stop charge on completion or timeout.
  • Timestamp every test with the RTC and export results as CSV over UART.
  • Report capacity with an uncertainty estimate and test-to-test repeatability.

What you need

From the EV Embedded Development Kit

  • STM32F103C8T6 microcontroller unit (Arm Cortex-M3)
  • 1S battery with connector and T-sense input
  • Battery charging unit with its own switch
  • Charge/discharge control relay
  • Load section: three switchable resistive loads with LEDs
  • RTC with CR2032 backup cell
  • Serial UART interface
  • 16×2 LCD with contrast control

Software

  • STM32CubeIDE
  • Embedded C with STM32 HAL
  • Python with pyserial and pandas

Extra parts

None. Everything this project needs is on the kit.

This project uses the kit's lithium cell. Respect polarity, never short the terminals, and don't leave the cell charging unattended.

Key concepts

Capacity (Ah) and energy (Wh)
Capacity is the integral of current over the discharge; energy is the integral of voltage times current. Energy depends more strongly on the discharge rate because voltage sags under higher load.
C-rate
Current expressed relative to capacity: 1C discharges the cell in about one hour. Lower C-rates usually deliver slightly more capacity.
Rest period
Waiting after charge or discharge lets the voltage settle, so each test starts from a comparable state.
Cut-off voltage
The voltage at which discharge stops. Moving it changes the measured capacity, so it must be fixed and reported with the result.

Step-by-step guide

  1. 1

    Write the test procedure

    Define the sequence: charge until the charging unit reports completion or a voltage-and-time rule says full, rest 60 minutes, discharge on a fixed load combination to the cut-off voltage, rest 30 minutes. Choose the cut-off above the cell's rated minimum. Calculate the expected C-rate from the load resistance and the cell's nominal capacity. Write the procedure as numbered steps with limits for every stage, including a maximum charge time.

    Checkpoint: A written procedure with voltage, time and temperature limits for every stage.

  2. 2

    Prepare the board

    Check cell polarity and connector seating. Enable the DIP switches for battery sense, T-sense, charge/discharge relay, loads, RTC, LCD and UART. Identify in the kit pin map how the firmware can control or observe the charging unit; if it only has a manual switch, the procedure prompts the operator on the LCD to switch it at the right moment. Charging must always be supervised.

    Checkpoint: Each block responds to a small test program, and the team knows exactly which charge steps are automatic and which are manual.

  3. 3

    Set and read the RTC

    Initialise the RTC, set the date and time over UART from the PC once, and check that it keeps time across a power cycle with the CR2032 fitted. Write a function that returns an ISO-style timestamp string. Every test record will begin with the start time and every log line will carry elapsed seconds from a timer for precision. Store the test start time in every summary so results can be ordered later.

    Checkpoint: After switching the board off for five minutes, the RTC still shows the correct time within a second.

  4. 4

    Calibrate voltage and loads

    Calibrate the cell-voltage reading against a multimeter at two points. With the board unpowered and cell disconnected, measure the resistance of the load combination you will use. Measure the board's quiescent current once with a multimeter in series so you know how much the board itself draws during the test. Record these constants in the firmware and in the report.

    Checkpoint: A calibration record with voltage gain and offset, load resistance and quiescent current.

  5. 5

    Integrate capacity and energy

    In a 1 s timer tick during discharge, estimate current as V / R_load plus the quiescent current, then add current × 1 s to a mAh accumulator and V × I × 1 s to a mWh accumulator. Use integer microvolt and microamp units or 64-bit accumulators so nothing overflows in a multi-hour test. Work out the uncertainty from the resistance measurement, heating drift and voltage error.

    Checkpoint: A short 10-minute discharge gives mAh within your stated uncertainty of the hand calculation from logged values.

  6. 6

    Build the test sequencer

    Implement the procedure as a state machine: IDLE, CHARGE, REST_1, DISCHARGE, REST_2, DONE, ABORTED. Each state has entry actions (switch relay, loads, prompts), an exit condition and a timeout. The LCD shows state, elapsed time, voltage and running mAh. The keypad starts and aborts the test. Abort on temperature over limit, implausible voltage or timeout, leaving loads off and the relay open.

    Checkpoint: A dry run with shortened times walks through every state in order, and pressing abort in any state leaves the cell disconnected.

  7. 7

    Export data

    Send one CSV line per second over UART with timestamp, state, voltage, estimated current, temperature, mAh and mWh. At the end, send a summary line: start time, cut-off voltage, load, capacity, energy, average voltage, duration and maximum temperature. Write a Python script that logs the stream and appends the summary to a results file so test history builds up over several runs.

    Checkpoint: A results file with the summary of a completed test and a matching per-second log.

  8. 8

    Run repeat tests

    Run at least three complete tests on the same load. Then run one at a different load combination to see the rate effect. Keep the room temperature roughly constant and record it with the BMP280 or a thermometer. Compute mean capacity and its spread; compare the spread with your calculated uncertainty. Use the same rest times and the same charging procedure before every run so differences come from the cell and the load, not from the procedure. Note any run you had to abort and why.

    Checkpoint: A table of at least four tests with capacity, energy, average voltage and ambient temperature.

  9. 9

    Analyse and report

    Plot voltage against discharged mAh for all runs on one chart; well-behaved tests overlay closely. Discuss the rate effect between the two loads and why energy changes more than capacity. Write the report with procedure, calibration, uncertainty analysis, results and limitations, including that current is estimated rather than measured. Calculate the C-rate of each test from the measured average current and capacity, and compare the results with the rated capacity on the cell label, explaining any difference instead of adjusting the numbers.

    Checkpoint: A report whose capacity figure includes an uncertainty and is backed by repeat tests.

Testing & validation

  • RTC timekeeping across power cycles.
  • mAh integration checked against logged data by hand calculation.
  • Repeatability of capacity across at least three tests.
  • Abort paths tested for temperature, timeout and keypad abort.

Expected results

An automated capacity tester with timestamped records, a measured capacity and energy for the kit cell with uncertainty, and a comparison of results at two discharge rates.

Take it further

  • Store the test history in SPI flash and show it in a menu on the LCD.
  • Repeat over many cycles and track capacity fade as a state-of-health indicator.
  • Add an INA219 add-on and compare measured with estimated current.
  • Send the summary over Bluetooth to a phone with an HC-05 add-on on the Bluetooth header.

Viva and review questions

Why does the measured capacity depend on the cut-off voltage?

Discharge stops when the voltage reaches the cut-off; a lower cut-off allows more charge to be removed. Results are only comparable with the same cut-off.

Why rest the cell before discharge?

Right after charging, the voltage is raised by polarisation. Resting lets it settle so each test starts from a comparable state.

How is current found in your tester?

As measured cell voltage divided by the calibrated load resistance, plus the measured quiescent current of the board, with an uncertainty from resistance drift and voltage error.

Why does energy fall more than capacity at a higher load?

At higher current the voltage sags more, so each mAh is delivered at a lower voltage, reducing Wh even if mAh changes little.

Related EV projects

All 100 EV projects