# Wind turbine To determine the state of charge (SoC) or percentage of fill for your 4 LiFePO₄ (Lithium Iron Phosphate) batteries, you typically use the battery voltage as an indicator. However, LiFePO₄ batteries have a very flat voltage curve, so voltage-based SoC estimation is only accurate at the extremes (fully charged or nearly empty) and less precise in the middle. Here’s how you can estimate the percentage: Measure the total voltage of your battery pack (in series, 4S = 4 cells in series). Reference a LiFePO₄ voltage-to-SoC table (see below). Map the measured voltage to a percentage using the table. Typical 4S LiFePO₄ Voltage-to-SoC Table | Voltage (4S) | SoC (%) | | ------------ | ------- | | 14.6V | 100% | | 13.6V | 99% | | 13.3V | 90% | | 13.2V | 70% | | 13.1V | 40% | | 12.8V | 20% | | 12.0V | 10% | | 10.0V | 0% | - **Fully charged (100%)**: 14.4V–14.6V (3.6V–3.65V per cell) - **Nominal (50%)**: ~13.2V (3.3V per cell) - **Empty (0%)**: 10.0V (2.5V per cell, but avoid discharging this low) ## Steps to Implement Read the battery voltage using an ADC (Analog-to-Digital Converter) on your ESP32. Map the voltage to SoC using the table above (linear interpolation for values in between). Display or use the percentage as needed. Example (Pseudocode) ```cpp float voltage = read_battery_voltage(); // Implement this for your hardware float soc = 0; if (voltage >= 14.6) soc = 100; else if (voltage >= 13.6) soc = 99; else if (voltage >= 13.3) soc = 90; else if (voltage >= 13.2) soc = 70; else if (voltage >= 13.1) soc = 40; else if (voltage >= 12.8) soc = 20; else if (voltage >= 12.0) soc = 10; else soc = 0; ``` > **Notes** > For best accuracy, measure voltage after the battery has rested (no load or charging for 30+ minutes). > For more precise SoC, use a battery management system (BMS) with coulomb counting.