One of the main problem in battery powered projects is to choose/use the proper battery size/model/type. As market is flooded now with a lot of low quality batteries claiming thousands of mAh ( Ultrafire fakes stories is just an example) the only way to proper check them is to run a set of tests.

A simple basic tester that will be able to monitor over the entire battery lifetime at least few parameters like, voltage, current, power consumption and stored energy between charges can give you valuable informations about the parameters and health of the battery. And of course also you can see how are looking the numbers against the datasheet claims :).

## Step 1: What we will need:

- CBDBv2 Evo Board ( or any other ESP8266 Board you may like but who has voltage/current measurement capabilities)
- INA21x – Current shunt monitor
- USB adapter (take a look here for more details about the USB Adapter)
- Li-Ion Battery Module
- 2 x 10 Ω /10 W resistors
- Connection wires – various colors

## Step 2: Schematic & Wiring

As the CBDBv2 Evo DevBoard has already Voltage and Current measurements capabilities onboard, the only thing that we will need to do is to connect the battery module that we want to measure to the board:

**WIRING:**

- GREEN – V+
- BLUE – GND
- RED – SH_IN+
- WHITE – SH_IN-

For that ones of you that want to use a different Board or just want to add these functions to a ESP8266 Module, you just need:

- for Voltage – add and size on your needs the voltage divider as explained in details in the previous article about ESP8266 Internal ADC.
- for Current – add your favourite Current Monitor but don’t forget about the VmaxIN for ESP8266 ADC of about 1V!

## Step 3: How to Measure Battery Parameters

When measuring the real battery capacity what we are interested in is the amount of energy stored in a battery since it is this energy we need to power our devices. Stored energy is measured in Watt-hours – the same unit used to measure our domestic electricity consumption (where 1,000Wh = 1kWh = 1 unit of electricity).

In order to measure the stored energy in a battery a power resistor is used as the load, and a fully charged battery is fully discharged through it. By measuring the voltage across this resistor at regular intervals during the discharge process it is simple to calcuate the total energy dissipated and therefore the total energy which had been stored in the battery.

Using Ohm’s Law (I=U/R) we can then calculate the current flowing through the load since we know the voltage across it. Instantaneous power is given by multiplying the measured voltage by the calculated current (P=U*I).

By taking readings for a certain amount of time until the battery is completly discharged, and adding up the energy dissipated in each time interval, we can calculate the total energy taken from the battery and dissipated in the resistor and therefore the total energy that was stored in the fully charged battery.

For More Details: WIFI Battery Monitor System – ESP8266