When the ESP32 is reset it comes up in mode where it is monitoring each of the battery's cell voltages. Every one second, voltage measurements are taken, and any current flowing through the battery total charge is accumulated. The data is stored in the esp from the time it is started, as the time interval expands older data is averaged and newer data is decimated over an expanding window so that between 64 and 128 equally spaced data points are stored in the esp. An I2C interface to an OLED display provides real time monitoring of state. 

The esp runs in one of four modes:

  • Monitoring : reads and stores battery cell voltages,
  • Charging : provides a programmable battery stack current to charge the device, monitors cell voltages and keeps track of accumulated charge supplied to battery stack
  • Discharging : places selectable load on battery, monitors cell voltages and keeps track of accumulated charge discharged from battery stack.
  • Storage : charges or discharges battery so that each cell is at approximately 3.8 volts.

The esp is also running a web server that hosts a webpage for the control of and more detailed monitoring of the state of the running application. The webpage does not need to be connected to the system while running, but control of the unit is performed by the webpage (or a curl command). The data for graph of cell voltages vs elapsed time since reset is stored in the esp and not by the browser, so the browser does not need to be connected during operation and can be accessed from several clients at the same time (so you can check out progress from your cell phone for example).

Discussion - 

The two webpage snapshots that are included in gallery show the discharge of two different 2S/350mA-hr batteries that were included with a minidrone that my daughter got for Christmas, they have gone through about 20 use cycles. Analyzing this data shows us that each of the batteries have well matched cells and all exceed their rated charge specifications. The series resistance on each cell (including hookup wire) is about 0.8ohms. The charger that came with the kit takes about two hours to charge a battery and the minidrone flight time is about 8 minutes, so I'm guessing that the charge rate of the charger is about 200mA and the discharge rate during flight is about 3 Amps (~10C).

Going Forward -

I have not implemented the charger yet, plan on using a 0.25ohm source follower on my current source fet in series with the battery pack with a 12V/2A wall transformer type power supply, thinking of using a simple pcf8591 module to provide gate current - or might use filtered esp pwm output, but in that case would have to boost the 3.3v output of the esp to get high enough gate voltage to the source followed fet. We'll see.

Have not really figured out what to do about dealing with the heat generated by the discharge loads - would like to get them up to 40 Watts for my larger batteries - would like to have a 3 or 4 ohm minimum load (or is it maximum?).

1/9/2020 - Have the current source working, only tested to a couple hundred milliamps - still need to get higher current power supply and heat sinks setup. So far closes good and stays stable.

Tested a couple type of single cell li-ion batteries that were sitting on my desk (my understanding is that li-ion and lipo batteries are similar chemically - differing in packaging technology).

2x parallel 18650 2000mAh salvaged from four year old laptop battery pack (or some cordless drills, etc..) - these came out pretty much as expected, less than .1ohms series impedance, handled 2A current draw well and capacity measured at over 90% of specification (picture in gallery - labeled 2x 18650).

18650 10000mAh (GTL - from china ~2/ea) -  these also came out pretty much as expected I suppose. Series impedance ~0.7ohms, does not handle 1A+ current draw at all well and rated capacity overstated by ~50x! The batteries weigh about half as much as the above batteries (hint...

Read more »