关于 battery-selector
battery-selector 帮助嵌入式项目开发者比较电池化学体系,并选择电芯和充电电路。其计算器依据电流消耗和运行时间评估电池选择,并提供化学体系参考与安全指南。
主要功能
- 01比较 15 种以上电池类型
- 02根据电流和运行时间估算容量
- 03筛选可充电电池
- 04查看充电与电压调节方案
- 05查阅各类电池的安全指南
适用场景
- 01为便携项目选择电池
- 02按目标运行时间估算容量
- 03选择可充电体系和充电器
- 04使用电池前核对安全事项
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ wedsamuel1230/ embedded-engineering-skills --skill battery-selector安装后在 Claude Code 中输入/battery-selector确认已加载。
附带文件references/safety-guidelines.mdscripts/compare_batteries.py
详细介绍
电池选择器
为嵌入式项目提供电池化学体系和充电电路选择指南。
资源
此技能包含随附的工具和参考资料:
- scripts/compare_batteries.py - 电池对比计算器,支持 15 种以上电池类型
- references/safety-guidelines.md - 涵盖所有化学体系的全面安全指南
快速开始
交互式选择:
uv run --no-project scripts/compare_batteries.py --interactive
命令行:
# Find battery for 50mA project, 24h runtime
uv run --no-project scripts/compare_batteries.py --current 50 --hours 24
# Require rechargeable
uv run --no-project scripts/compare_batteries.py --current 100 --hours 12 --rechargeable
# List all batteries in database
uv run --no-project scripts/compare_batteries.py --list
适用场景
- “我应该使用哪种电池?”
- “如何为这个项目充电?”
- “锂电池还是碱性电池?”
- “这种电池安全吗?”
- 规划便携式/电池供电项目
决策流程图
START
│
▼
Is project rechargeable? ──No──► Alkaline/Lithium Primary
│ (Disposable batteries)
Yes
│
▼
What voltage does MCU need?
│
├── 5V ──► LiPo + Boost converter
│ OR 3x/4x NiMH
│
├── 3.3V ──► Single LiPo (3.0-4.2V)
│ Directly compatible!
│
└── 12V+ ──► Multi-cell LiPo pack
OR Lead-acid
│
▼
How much current?
│
├── <50mA ──► Small LiPo (500-1000mAh)
│ OR Coin cell (CR2032)
│
├── 50-500mA ──► Standard LiPo (1000-3000mAh)
│ OR 18650 cells
│
└── >500mA ──► Large LiPo (3000mAh+)
OR Multiple 18650s
External power recommended
电池化学体系对比
快速参考
| 化学体系 | 电压 | 可充电 | 能量密度 | 成本 | 安全性 |
|---|---|---|---|---|---|
| 碱性电池 | 1.5V/节 | 否 | 中 | 低 | 非常安全 |
| 一次锂电池 | 3V | 否 | 高 | 中 | 安全 |
| NiMH | 1.2V/节 | 是 | 中 | 中 | 安全 |
| LiPo/Li-ion | 3.7V | 是 | 非常高 | 中 | ⚠️ 需要谨慎 |
| LiFePO4 | 3.2V | 是 | 高 | 高 | 比 LiPo 更安全 |
| 铅酸电池 | 2V/节 | 是 | 低 | 低 | ⚠️ 有酸液危险 |
碱性电池(AA/AAA/9V)
优点:
- 价格便宜,随处可买
- 无需充电电路
- 非常安全
- 保质期长(5-10 年)
缺点:
- 不可充电(会产生电子垃圾!)
- 放电时电压会下降
- 不适合大电流
- 单位容量较重
适用场景:
- 低功耗项目(平均电流 <20mA)
- 入门项目
- 充电不方便的远程/部署场景
- 备用电源
电压配置:
Cells Voltage Use With
────────────────────────────
2x AA 3.0V 3.3V MCUs (with LDO)
3x AA 4.5V 5V MCUs (direct or LDO)
4x AA 6.0V 5V MCUs (with regulator)
9V 9.0V With 5V/3.3V regulator
NiMH(AA/AAA 可充电电池)
优点:
- 可充电(500-1000 次循环)
- 尺寸与碱性电池相同
- 比锂电池更安全
- 无记忆效应
缺点:
- 电压较低(1.2V 对比 1.5V)
- 自放电(约 20%/月)
- 需要合适的充电器
- 比 LiPo 重
适用场景:
- 替换一次性电池的项目
- 教育环境
- LiPo 风险过高的场景
- 经济型可充电方案
充电:
- 使用专用 NiMH 充电器
- 不要混用不同品牌或容量的电池
- 推荐使用 Eneloop/Eneloop Pro
LiPo / Li-ion(3.7V)
优点:
- 能量密度高(轻巧且动力强)
- 可充电(300-500 次循环)
- 放电曲线平坦
- 外形规格多样
缺点:
- ⚠️ 使用不当有起火风险
- 需要保护电路
- 对温度敏感
- 即使不使用也会老化
适用场景:
- 大多数便携式项目
- 对重量敏感的应用
- 需要较长续航时间的场景
- 专业项目
关键安全规则:
✅ DO:
- Use protected cells with BMS
- Store at 40-60% charge
- Use proper TP4056/similar charger
- Monitor temperature during charge
- Use battery with JST-PH connector (prevents polarity swap)
❌ DON'T:
- Puncture, crush, or bend
- Charge below 0°C
- Discharge below 3.0V
- Leave charging unattended (first few times)
- Use damaged/puffy batteries
LiFePO4(3.2V)
优点:
- 比 LiPo 安全得多(不会发生热失控)
- 循环寿命更长(2000 次以上)
- 放电曲线平坦
- 耐受不当使用的能力更强
缺点:
- 能量密度较低
- 电压较低(可能需要升压)
- 价格更高
- 小尺寸规格较少见
适用场景:
- 对安全要求严格的应用
- 户外/坚固耐用的部署
- 长期安装
- 无法接受 LiPo 风险的场景
CR2032 / 纽扣电池
优点:
- 体积小、重量轻
- 保质期长
- 输出 3V(可直接连接 3.3V MCU)
缺点:
- 容量非常低(220mAh)
- 大电流性能差
- 不可充电
- ⚠️ 吞食后有危险
适用场景:
- 仅限超低功耗场景(平均电流 <10µA)
- RTC 备用电源
- 微型传感器
- 钥匙扣、信标
电流限制:
Continuous: <2mA
Pulse: <15mA (brief)
DON'T use for: WiFi, Bluetooth, motors, LEDs
电压调节
3.3V 系统(ESP32、RP2040)
单节 LiPo → 3.3V:
LiPo outputs 3.0-4.2V
Most 3.3V MCUs tolerate this range directly!
Option 1: Direct connection (if MCU allows)
LiPo(+) → 3.3V/VIN pin
Option 2: LDO for clean 3.3V
LiPo(+) → [AMS1117-3.3] → 3.3V pin
(Need 4V min input for AMS1117)
Better: Use HT7333 LDO (low dropout, low quiescent)
Works from 3.3V input!
5V 系统(Arduino UNO/Nano)
LiPo → 5V:
Option 1: Boost converter
LiPo(+) → [MT3608] → 5V → VIN pin
Option 2: PowerBoost module (Adafruit)
Includes charging + boost + protection
Option 3: USB power bank
Already regulated 5V + charging built-in
充电方案
TP4056 模块(最常用)
┌─────────────────────────────┐
│ TP4056 with Protection │
│ │
│ [USB-C] ─► [TP4056] ─► [DW01+FS8205] ─► [B+/B-]
│ IN Charger Protection To Battery
│ │
│ Features: │
│ - 1A max charge current │
│ - Overcharge protection │
│ - Overdischarge protect │
│ - Short circuit protect │
│ - LED charge indicator │
└─────────────────────────────┘
Wiring:
B+ → LiPo positive
B- → LiPo negative
OUT+ → Load/MCU positive
OUT- → Load/MCU negative
⚠️ 请购买带保护功能的模块(6 个引脚,而非 4 个引脚)
Adafruit PowerBoost 500C/1000C
高端方案,包含:
- 通过 USB 为 LiPo 充电
- 5V 升压输出(500mA 或 1A)
- 低电量指示灯
- 负载共享(运行时可充电)
DIY 充电注意事项
❌ Never charge LiPo with a constant voltage supply
❌ Never charge LiPo with a phone charger directly
❌ Never charge at >1C rate (e.g., 1000mAh → max 1A)
❌ Never charge frozen batteries
电池容量计算器
Step 1: Determine average current (from power-budget-calculator)
I_avg = _____ mA
Step 2: Determine required runtime
T_required = _____ hours
Step 3: Calculate minimum capacity
C_min = I_avg × T_required × 1.25 (safety factor)
C_min = _____ × _____ × 1.25
C_min = _____ mAh
Step 4: Select battery
Choose capacity ≥ C_min
Consider: size, weight, form factor
示例:
Project: Weather station
I_avg: 15mA
T_required: 48 hours (2 days between charges)
C_min = 15 × 48 × 1.25 = 900mAh
Selection: 1000mAh LiPo (gives ~67 hours actual)
常见错误
1. 使用错误的充电器
❌ "My 9V adapter should work"
LiPo needs CC-CV charging at 4.2V max!
✅ Use TP4056 or dedicated LiPo charger
2. 未设置低电压截止
❌ Draining LiPo below 3.0V
Permanently damages the cell!
✅ Use protection module OR monitor in code:
if (batteryVoltage < 3.2) {
enterDeepSleep(); // Protect battery
}
3. 忽略浪涌电流
❌ Battery can't handle WiFi TX spike (500mA)
Causes brownout/reset
✅ Add 100-470µF capacitor near MCU
✅ Size battery for peak current, not just average
4. 无反接保护
❌ Swapping battery wires = magic smoke
✅ Use JST-PH connectors (keyed)
✅ Add protection diode or P-FET
按项目类型推荐的配置
低功耗传感器节点
Battery: 18650 (3000mAh) or LiPo 2000mAh
MCU: ESP32 with deep sleep
Charger: TP4056 with protection
Runtime: Weeks to months
手持设备
Battery: LiPo 1000-2000mAh flat pack
MCU: Any
Charger: PowerBoost or TP4056 + boost
Runtime: Hours to days
机器人/大电流
Battery: 2S or 3S LiPo pack (7.4V or 11.1V)
Regulator: Buck converter to 5V
Charger: Balance charger (external)
Runtime: Minutes to hours
超低功耗信标
Battery: CR2032 or 2x AA
MCU: ESP32-C3 or ATtiny with deep sleep
No charger needed
Runtime: Months to years
快速选择表
| 项目类型 | 最佳电池 | 容量 | 充电器 |
|---|---|---|---|
| 简易 Arduino | 4 节 AA 电池 | 2500mAh | 无 |
| 便携式 ESP32 | 18650 | 2600mAh | TP4056 |
| 可穿戴设备 | 小型 LiPo | 500mAh | TP4056 |
| 机器人 | 2S LiPo | 2200mAh | 均衡充电器 |
| 超低功耗 | CR2032 | 220mAh | 无 |
| 太阳能项目 | LiFePO4 | 3200mAh | MPPT |
共享输出约定
使用共享的 Arduino 技能约定: 说明假设、所需工具和版本、实现步骤、 按验证阶段列出的测试/证据、已知限制,以及恢复/安全说明。
评论
支持 Markdown