In my recent project, I set out to develop a Battery Management System (BMS) and a companion mobile app for a lithium battery pack. One of the key decisions I faced was whether to use a single ESP32 chip or a dual-MCU setup with STM32 and ESP32. This choice affects not only the reliability of the system but also the hardware cost, development complexity, and future maintenance.
Battery Pack Overview
The battery pack I’m working with is 5S2P, with a total voltage around 18–21V. “5S” means five cells in series, and “2P” means two parallel strings. Even though it’s not a huge pack, it still requires accurate monitoring of voltage, current, and temperature to operate safely, especially during charging and discharging. Getting the measurements and protection right is critical.
Option 1: STM32 + ESP32
The first approach is the traditional and safer one: use STM32 as the main controller for battery management, and an ESP32 for wireless communication and app connectivity.
STM32 takes care of:
- Measuring each cell’s voltage
- Reading current and temperature
- Running protection logic (overvoltage, undervoltage, overcurrent, overtemperature)
- Managing charging and discharging, including constant current/constant voltage (CC/CV) charging
- Balancing cells to keep them uniform
ESP32 handles:
- WiFi and Bluetooth communication
- Uploading battery data to a mobile app
- Receiving remote commands and sending them to STM32
- Supporting over-the-air (OTA) firmware updates
The main advantage here is safety and reliability. STM32 focuses on real-time control and protection, while ESP32 handles communication. The downside is slightly higher cost and a more complex system overall.
Option 2: ESP32 Only
The other approach is to use ESP32 alone to manage both the battery and wireless communication. This is appealing because it reduces cost and simplifies the hardware.
ESP32 is a capable chip with WiFi, Bluetooth, ADCs, PWM, I²C, SPI, and other peripherals. In theory, it can measure voltage, current, and temperature and implement basic protection and charging control. For smaller battery packs, this can work fine.
But there are some concerns:
- Real-time performance: Running WiFi or Bluetooth on ESP32 can occupy CPU resources, which might delay battery protection actions. Quick voltage or current changes could become risky.
- Measurement accuracy: ESP32’s built-in ADCs aren’t very high precision. Without external ADCs or an analog front-end (AFE), voltage or current readings could be off, affecting SOC calculations and protection triggers.
- Safety redundancy: In a dual-MCU setup, protection is separated from communication. If the ESP32 crashes, STM32 still handles safety. A single-chip system doesn’t have this backup.
- Low-power operation: ESP32’s deep sleep power draw is higher than many low-power MCUs. For applications needing long standby times, this could be a limitation.
Comparing the Two Approaches
Looking at the options side by side:
- Safety: STM32 + ESP32 is more reliable for real-time protection and safe charging.
- Cost: ESP32-only reduces hardware cost but may require extra sensors or protection circuits.
- Development: Dual-MCU is easier to develop since tasks are clearly separated. Single-chip solutions have to juggle protection and wireless, increasing complexity.
- Future flexibility: STM32 + ESP32 makes it easier to add features or upgrade wireless protocols without affecting core BMS functions.
Given these points, I feel the STM32 + ESP32 setup fits this 5S2P battery pack better. Yes, it’s a bit more expensive, but the extra safety and reliability make it worth it.
