When working with 18650 cells in custom battery packs, safety and performance depend heavily on the battery management system (BMS). Whether you're building a power source for IoT devices, robotics, or portable energy storage, integrating the right BMS firmware is just as important as the hardware itself.
As a lithium battery manufacturer that works with engineers on both OEM and ODM battery solutions, we’ve seen how small changes in firmware can make a big difference, especially in projects using 18650 batteries.
In this post, we’ll walk through core elements of BMS firmware, show some code examples, and offer insights from real-world projects.
Why You Need a Custom BMS
Off-the-shelf BMS boards often provide only the basics: overcharge protection, overdischarge cutoff, and short-circuit protection. But if you want:
- Accurate state of charge (SoC) estimation
- Smarter balancing between cells
- Thermal control and logging
- Communications with a host device
…then you'll likely need to customize your BMS firmware.
Working with 18650 batteries adds extra complexity. These cells are sensitive to voltage imbalance, especially in packs with multiple parallel or series configurations. That’s why having tight control over your battery logic is key.
Example: Basic Voltage Protection Logic in C
Here’s a simple C-based BMS logic block for undervoltage protection on a pack using three 18650 cells in series.
#define CELL_COUNT 3
float cell_voltages[CELL_COUNT];
float UV_THRESHOLD = 3.0; // Undervoltage threshold (V)
bool undervoltage_detected(float voltages[]) {
for (int i = 0; i < CELL_COUNT; i++) {
if (voltages[i] < UV_THRESHOLD) {
return true;
}
}
return false;
}
In a more advanced version, you’d log which cell triggered the shutdown, timestamp the event, and send data to a host via UART or CAN.
Adding Cell Balancing Logic
When the pack is charging, small imbalances between cell voltages can affect lifespan. Here’s a simplified way to check if passive balancing should kick in:
#define BALANCE_THRESHOLD 0.03 // 30mV difference
void balance_cells(float voltages[]) {
float max_v = voltages[0];
for (int i = 1; i < CELL_COUNT; i++) {
if (voltages[i] > max_v) {
max_v = voltages[i];
}
}
for (int i = 0; i < CELL_COUNT; i++) {
if (max_v - voltages[i] > BALANCE_THRESHOLD) {
// Activate bleed resistor on cell i
enable_bleed(i);
} else {
disable_bleed(i);
}
}
}
Of course, actual balancing logic should include timers, temperature checks, and current flow monitoring.
Real-World Notes from the Factory Floor
At Ufine Battery, we build many custom 18650 battery packs for small devices, IoT systems, and industrial tools. While we’re not the biggest lithium battery manufacturer in the world, our strength is in customization.
We’ve worked on projects where the client needed:
- Low-temperature 18650 packs for sub-zero environments
- Slim 3-cell modules for smartwear and handheld sensors
- High-discharge packs with custom BMS code and Bluetooth telemetry
One reason engineers like working with us is flexibility. We support one-piece minimum orders, fast shipping, and provide detailed, responsive service. Many of our customers start with a prototype run and grow from there. And every pack comes with a one-year warranty.
It’s also worth noting that we offer a wide range of lithium battery types—not just 18650, but also lithium-ion, LiFePO4, ultra-thin, high-temperature, and high-rate cells.
Tips for Developers Integrating a BMS
- Test in hardware-in-the-loop (HIL): Run your firmware on a dev board while simulating cell voltages and current.
- Include error flags and timeouts: Don't assume hardware is always honest.
- Protect against CAN/UART spam: Limit transmission frequency.
- Use NTCs: Thermal sensors prevent overheating, especially in small enclosures.
- Keep firmware modular: Separate voltage protection, balancing, and comms into different files or classes.
Final Thoughts
Working with 18650 batteries means more than just stacking cells and wiring a BMS. With custom firmware, you gain precision, reliability, and safety, which is crucial in embedded systems and consumer products alike.
Whether you're developing a wearable sensor or a backup power system, a well-designed BMS makes the difference. And if you're looking for a lithium battery partner who can support you from prototype to production, Ufine Battery is a great place to start.
Let me know in the comments how you’re handling battery management in your projects, or feel free to share your firmware snippets.
Top comments (0)