
Machine Learning
ML-Based EV Battery State-of-Charge (SoC) Prediction
Abstract
The ML-Based EV Battery State-of-Charge (SoC) Prediction System is designed to estimate the remaining charge percentage of an electric vehicle battery using voltage, current, and temperature measurements. The system collects battery operating data and analyses it using Python-based machine learning techniques. Models such as Random Forest, XGBoost, and LSTM can learn battery charge-discharge patterns and estimate the State of Charge. The project aims to improve battery monitoring, support efficient charging decisions, and provide better energy management.
Project Description
This project develops an intelligent battery monitoring and SoC prediction solution for electric vehicles using a battery pack, voltage sensor, current sensor, and temperature sensor.
An ESP32 can collect real-time battery measurements, including voltage, charging or discharging current, and temperature. The collected data is transmitted to a Python-based application for preprocessing, feature extraction, and machine learning analysis.
Machine learning algorithms such as Random Forest and XGBoost can estimate SoC using extracted battery features, while LSTM can analyse sequential battery measurements to learn charge-discharge behaviour over time.
The system can display the estimated battery charge percentage, measured electrical parameters, charging trends, and low-battery alerts through a web dashboard.
Working Principle
1. Sensor Data Collection: Voltage, current, and temperature sensors monitor the battery pack during charging and discharging.
2. Data Acquisition: The ESP32 collects sensor readings and transmits the measurements to the Python application.
3. Data Preprocessing: Python cleans, filters, and prepares the collected measurements for machine learning.
4. Feature Extraction: Relevant features such as voltage, current, temperature, measurement changes, and operating time are extracted.
5. Model Training: Train Random Forest, XGBoost, or LSTM models using labelled battery data with reference SoC values.
6. SoC Prediction: The trained model estimates the battery's remaining charge as a percentage between 0% and 100%.
7. Dashboard Monitoring: Display real-time voltage, current, temperature, predicted SoC, and battery usage trends.
8. Alert Generation: Generate notifications when the estimated SoC reaches configured low-battery thresholds.
Notes
- The project can be implemented using a physical battery pack or a historical battery dataset.
- A labelled dataset containing voltage, current, temperature, and reference SoC values is required for supervised machine learning.
- Random Forest and XGBoost can be evaluated for feature-based SoC estimation, while LSTM can be used for sequential battery measurements.
- SoC is not determined reliably by voltage alone, especially under changing load conditions.
- Current measurement, temperature, battery chemistry, charge-discharge history, and battery ageing can influence SoC estimation.
- Coulomb counting and BMS-reported SoC can provide useful reference information for model training and validation.
- Model performance should be evaluated using MAE, RMSE, and other suitable regression metrics.
- Training and testing data should be separated carefully to avoid data leakage between battery cycles.
- Sensor calibration and suitable sampling frequency are important for reliable measurements.
- A Battery Management System (BMS) should remain responsible for essential battery protection and safety functions.
- Use properly rated and isolated sensing circuits. Never connect high-voltage battery terminals directly to the ESP32.
- Physical battery testing requires suitable fuses, temperature monitoring, current limits, and a safe test environment.
Expected Outcome
The expected outcome is an intelligent EV battery monitoring prototype that measures voltage, current, and temperature and uses machine learning to estimate battery State of Charge. The system can display predicted SoC, real-time battery measurements, charging and discharging trends, and low-battery alerts. It demonstrates how Python, IoT hardware, and machine learning can support improved battery monitoring, efficient charging decisions, and intelligent electric vehicle energy management.
All Projects




