All projectsEmbedded Systems & IoT

ESP32-Based Smart 4S Battery Monitoring System

Designed and programmed an ESP32-based monitoring system for four-cell series-connected lithium-ion battery packs as an independent freelance project. The prototype uses resistor-divider sensing to monitor individual cell voltages, calculate total pack voltage and identify voltage differences. An OLED display, push-button interface and custom Wi-Fi dashboard provide local and wireless access to battery measurements.

ESP32Battery MonitoringBattery Management Research4S Lithium-IonEmbedded SystemsIoTVoltage MeasurementCell Voltage MonitoringBattery TelemetryAnalogue-to-Digital ConversionVoltage DividerSSD1306 OLEDI2CWi-FiWireless MonitoringWeb DashboardArduino C++HTMLCSSJavaScriptJSON APIElectronics PrototypingBattery ElectronicsSensor IntegrationFreelance Engineering
01

Project Overview and Motivation

The ESP32 Smart Battery Monitoring System was developed as a freelance embedded electronics project exploring the monitoring of individual battery cells through a compact, programmable microcontroller platform. Lithium-ion battery packs are commonly constructed by connecting multiple cells in series to obtain higher operating voltages. Although the complete pack has a measurable terminal voltage, this measurement alone does not reveal the electrical condition of each individual cell. Differences in cell voltage can develop as batteries charge, discharge and age. Monitoring individual cells therefore provides additional information about the pack's electrical condition beyond a single total-voltage measurement. The project investigates how an ESP32 microcontroller can acquire multiple analogue voltage measurements, process the readings and provide an accessible battery-monitoring interface. The intended solution combines individual cell monitoring, OLED-based visualisation and wireless telemetry within one embedded system. As a freelance project, the work also explores the practical process of developing a custom electronics monitoring solution around specific hardware and interface requirements.

02

System Objectives and Functional Requirements

The primary objective was to develop a monitoring platform capable of obtaining electrical measurements from a four-cell series-connected lithium-ion battery arrangement. The system needed to acquire voltage information from four cumulative battery taps and calculate the voltage of each individual cell. Another requirement was to provide total battery-pack voltage information and a numerical indication of voltage differences between cells. Because the ESP32 analogue inputs cannot directly measure the full voltage present across the battery pack, suitable signal conditioning was required to scale each measurement into the allowable ADC input range. The project also required a local user interface capable of displaying battery readings without relying on a connected computer. A wireless interface was included so that the same information could be accessed through a smartphone or laptop using a web browser. An additional design objective was to provide a basic temperature-sensing input that could be calibrated and integrated into the monitoring functions. The scope of the documented software was limited to measurement, processing and visualisation. Active battery protection and charge-management functions were not incorporated into this implementation.

03

ESP32-Based Electronics Architecture

The system uses a 30-pin ESP32 DevKit development board as the central embedded controller. The ESP32 was selected because it combines analogue measurement inputs, general-purpose digital I/O, I2C communication and Wi-Fi connectivity within a compact microcontroller platform. Four analogue inputs are allocated to battery-voltage measurement using GPIO 32, 33, 34 and 35. An additional analogue input on GPIO 36 is reserved for temperature-sensor information. The SSD1306 OLED display communicates through the ESP32's I2C interface using GPIO 21 for SDA and GPIO 22 for SCL. A physical push button is connected to GPIO 25 and is used to navigate between the display screens. The firmware coordinates analogue sampling, mathematical processing, display updates, web-server responses and user input. This architecture allows the battery-monitoring functions and wireless interface to operate on the same microcontroller without requiring a separate processing computer.

04

Four-Cell Voltage Sensing and Signal Conditioning

The battery-voltage monitoring architecture uses four cumulative measurement points referenced to the negative terminal of the series-connected battery pack. Because the measured voltages increase across the series connections, each tap is connected to an ESP32 analogue input through a resistor-divider network. The documented hardware configuration uses a 100 kΩ resistor and a 10 kΩ resistor for each voltage-sensing channel, providing a nominal voltage division ratio of eleven to one. The purpose of the divider is to reduce the voltage presented to the microcontroller's analogue inputs. The firmware then applies the corresponding scaling ratio to estimate the voltage at each battery tap. The system therefore obtains four cumulative voltage measurements, representing the battery potential at successive positions along the series-connected cell arrangement. Individual cell voltages are calculated from the differences between adjacent cumulative measurements. This approach reduces the requirement for separate measurement processors for each cell, although it introduces calibration and measurement-accuracy challenges. In particular, errors in the higher cumulative voltage readings can affect the calculated voltages of individual cells. The implementation therefore demonstrates a practical analogue sensing architecture while requiring appropriate electrical verification and calibration before the measurements can be considered reliable.

05

Cell Voltage Calculations and Battery Monitoring Logic

The ESP32 firmware converts the four cumulative battery tap measurements into the individual cell voltages required for monitoring. The first cell voltage is calculated directly from the first measured tap, using the battery pack's negative terminal as the reference. For the second, third and fourth cells, the firmware subtracts the preceding cumulative tap voltage from the current tap reading. This provides an estimate of the potential difference across each individual cell. The total battery-pack voltage is obtained from the fourth and highest cumulative battery tap. The application also calculates cell-voltage spread, defined as the difference between the highest and lowest individual cell voltages. This measurement provides a simple numerical indication of variation between the cells. However, voltage spread is not equivalent to a complete measurement of battery health or state of charge. The user interface also includes graphical voltage indicators based on an illustrative 3.0–4.2 V range for individual cells. These indicators are intended to provide a visual representation of voltage level and are not a calibrated battery state-of-charge estimator. The processing logic therefore provides basic battery electrical measurements without claiming to determine remaining capacity, state of health or remaining operating runtime.

06

ADC Sampling, Data Processing and Measurement Stability

The ESP32's internal analogue-to-digital converter is responsible for digitising the voltages presented by the sensing circuitry. The firmware configures a 12-bit ADC resolution and sets the analogue input attenuation for the selected measurement channels. To reduce variation between successive readings, the sampling function performs multiple measurements for each input. After switching to an analogue channel, the firmware discards the first conversion and collects 24 additional ADC readings. These measurements are averaged to obtain the sampled voltage used in the battery calculations. The averaging method is intended to reduce the influence of random fluctuations in the analogue measurements. The application schedules sensor acquisition approximately every 500 milliseconds. Each sampling cycle updates the cumulative tap measurements, derived cell voltages, total pack voltage, cell-voltage spread and available temperature-input information. While these techniques improve the consistency of sampled values, they do not independently establish absolute measurement accuracy. Reliable battery measurement still depends on correct wiring, component tolerances, ADC calibration and comparison with an independent reference instrument.

07

OLED Display and Physical User Interface

The battery-monitoring prototype incorporates a 128 × 64-pixel SSD1306 OLED display for local visualisation. The display communicates with the ESP32 through I2C and presents battery information using a compact graphical interface. Four individual display screens are allocated to the four monitored battery cells. Each screen identifies the selected cell and displays its calculated voltage in a large numerical format. A horizontal graphical indicator provides an illustrative representation of the voltage relative to the configured display scale. A fifth screen presents the analogue temperature-input information and total battery-pack voltage. Navigation between the five screens is controlled using a physical push button connected to the ESP32. The button-handling logic includes software debouncing to reduce unintended multiple screen changes caused by mechanical contact bounce. This interface provides a practical method of inspecting battery measurements directly at the electronics module without requiring access to the wireless dashboard.

08

ESP32 Wi-Fi Access Point and Web Dashboard

In addition to the OLED interface, the system incorporates a local wireless monitoring application hosted directly by the ESP32. The microcontroller operates in Wi-Fi access-point mode, allowing a smartphone or laptop to connect directly to the device. The firmware hosts an HTTP server and serves a responsive browser interface developed using HTML, CSS and JavaScript. The dashboard displays the four individual cell voltages, the total battery voltage, cell-voltage spread and available temperature-input information. The interface uses separate information cards for different values, together with graphical voltage indicators for the individual cells. A connection-status message indicates whether the browser is currently receiving updates from the device. The dashboard retrieves telemetry information through a JSON-based HTTP endpoint at /api/data. Browser-side JavaScript periodically requests updated data and refreshes the displayed readings without requiring a complete page reload. The application is configured to request new information approximately once per second. Because the interface is hosted locally by the ESP32, it does not depend on cloud infrastructure or an external internet connection. This architecture demonstrates the integration of embedded sensing, local web hosting and interactive browser-based monitoring in a single IoT device.

09

Temperature-Sensing Provision and Telemetry Data

The project includes an analogue input reserved for temperature monitoring. The firmware reads the sensor input through GPIO 36 and makes the raw ADC reading and corresponding measured analogue voltage available to the display and web dashboard. The temperature information is also included in the JSON telemetry response. However, the documented firmware does not contain a calibrated conversion from the input measurement into degrees Celsius. Consequently, the interface identifies the temperature information as an uncalibrated analogue reading rather than presenting an unsupported temperature value. The telemetry system also provides the four calculated cell voltages, total pack voltage, voltage spread and system uptime. A later troubleshooting version additionally exposes the original calculated cell voltages separately from adjusted display values. This separation is useful during debugging because it allows the unmodified measurement results to remain available for comparison. The sensor architecture is expandable, but additional temperature calibration and measurement validation are required before it can be used for dependable battery thermal monitoring.

10

Firmware Iterations and Voltage Measurement Troubleshooting

During development, several versions of the ESP32 monitoring firmware were prepared to refine the monitoring interface and investigate voltage-reading problems. The original monitoring firmware implemented the cumulative tap measurements, individual cell calculations, OLED display, Wi-Fi dashboard and JSON telemetry interface. A subsequent adjusted version introduced additional display-only offsets for the third and fourth cell readings. These offsets were intended for troubleshooting inconsistent displayed voltages and were explicitly identified in the code as unverified adjustments. The modified version retained access to the unmodified cell calculations, allowing the original readings to be distinguished from the values shown after the offsets. This distinction is important because manually adjusting displayed voltages does not correct an electrical connection problem, incorrect divider ratio or ADC calibration error. The voltage-offset method was therefore a temporary diagnostic modification rather than a validated measurement correction. The development process highlights a practical challenge associated with measuring individual cells from cumulative battery voltages: errors in the acquired tap measurements can propagate into the derived cell voltages. Further electrical validation is required to establish accurate measurements across all four cells and remove reliance on temporary display adjustments.

11

Implementation Results and Present Limitations

The available firmware demonstrates the software implementation of a multichannel battery monitoring and visualisation platform. The completed code includes analogue voltage sampling, mathematical cell-voltage derivation, battery-pack monitoring, voltage-spread calculation, OLED output, push-button navigation and a locally hosted Wi-Fi dashboard. The JSON telemetry endpoint provides a structured interface for displaying measurements in the browser and potentially supporting future software integrations. The code also includes basic handling for an unavailable OLED display, allowing the web interface to remain operational if display initialisation fails. However, the available records do not establish final calibrated measurement accuracy, repeatability under different battery conditions, successful thermal calibration or completed client acceptance testing. The documented version also does not implement active protective functions such as cell balancing, charging control, load disconnection, short-circuit protection or overcurrent interruption. These capabilities are normally essential to a complete battery management system and would require additional sensing, switching, protection and validation hardware. The current implementation is therefore best described as a battery monitoring and wireless telemetry prototype. Its principal demonstrated engineering work is the firmware architecture and integration of multiple monitoring interfaces, while final physical measurement validation remains to be confirmed.

12

Project Outcome and Future Scope

The ESP32 Smart Battery Monitoring System was developed to investigate how a programmable microcontroller can provide battery measurement and visualisation functions through a compact embedded electronics platform. The project resulted in a configurable firmware implementation supporting four-cell voltage monitoring, pack-voltage calculation, cell-voltage difference analysis, OLED visualisation and local Wi-Fi telemetry. The work provided practical experience in analogue signal conditioning, ADC measurement, embedded programming, mathematical processing, I2C peripherals, HTTP communication, JSON data transfer and responsive dashboard development. As an independent freelance engineering project, it also represents experience developing software and electronics functionality around a specified hardware application. Further improvements should focus first on validating the electrical measurements using independently measured reference voltages and implementing a suitable calibration procedure. The temperature-monitoring input also requires a defined sensor interface and a calibrated conversion into physical temperature units. Additional development could include persistent measurement logging, validated voltage thresholds, battery-health estimation and improved monitoring diagnostics. If the project is intended to become a complete protective BMS, a dedicated battery-protection architecture would also be required, including appropriate charging safeguards, overvoltage and undervoltage protection, current monitoring, protective switching and balancing functions. The existing ESP32 firmware provides a foundation for these future developments but does not replace a properly validated battery protection system. Overall, the project demonstrates the integration of battery-sensing concepts, embedded electronics and IoT visualisation within a custom monitoring platform.