# Calculating Li-Ion Battery Life for Your 5V Devices

Many electronics projects with Arduino, ESP32 boards requires 5V power supply to power them using batteries. Today, Lithium Ion batteries, Li-Po batteries are widely used to power the Arduino based projects, ESP32 and ESP-32 CAM projects. An obvious question is how long will the battery or batteries last to power the devices(electronic circuits including microcontroller and other components. For example, the bluetooth car with Arduino, ESP32-CAM video streaming and other system requires batteries. Here we want to answer a bit of how we can forecast or estimate how long the battery will last. For this example calculation, we will use Lithium Ion batteries and ESP32-CAM module. That is the ESP32-CAM is powered by two 18650, 3800mAh, 3.7VLi-Ion batteries via a LM7805 voltage regulator.

For example DIY +5V Regulated Power Supply for Breadboard is used to power the ESP32-CAM and we want to know how long the power supply could supply the ESP32-CAM module.

To calculate how long your batteries can supply power to a +5V device like an ESP32-CAM, we need to consider a few factors, including the battery capacity, the voltage conversion efficiency, and the power consumption of the device.

Here's a step-by-step guide to estimate the runtime:

1. Battery Capacity: Each 18650 battery has a capacity of 3800mAh at 3.7V.

2. Total Capacity: When using two batteries in series, the voltage doubles, but the capacity remains the same as a single battery:

$\text{Total Voltage} = 3.7V \times 2 = 7.4V$
3. Device Power Consumption: Determine the power consumption of the ESP32-CAM. Let's assume it consumes approximately 300mA at 5V.

4. Power Requirement: Calculate the power requirement of the ESP32-CAM:

$\text{Power} = \text{Voltage} \times \text{Current} = 5V \times 300mA = 1.5W$
5. Efficiency of Voltage Conversion: Assume the efficiency of the LM7805 regulator is around 60% (a typical linear regulator efficiency when dropping from 7.4V to 5V).

6. Effective Power from Batteries: Calculate the effective power available from the batteries considering the efficiency:


7. Runtime Calculation:

$\text{Runtime} = \frac{\text{Effective Power}}{\text{Device Power Consumption}}$ $\text{Runtime} = \frac{16872mWh}{1500mW} = 11.25 \text{ hours}$

Thus, under ideal conditions and assuming a constant power consumption of 300mA by the ESP32-CAM, your batteries should be able to supply power for approximately 11.25 hours.

Note however that the actual runtime can vary depending on factors such as the exact power consumption of the ESP32-CAM in different operating modes, the condition of the batteries, and the efficiency of the voltage regulator in your specific setup.

What next? How about using LM317 voltage regulator for power high power motors. See LM7805 vs LM317: Which Voltage Regulator to Use for Your Project and 3.7V Lithium Ion Auto Cutoff Battery Charger Circuit Design and Working Principle.