Battery Capacity Measurement Using Kitronik Inventor's Kit and Adafruit CLUE

by kevinjwalters in Circuits > Microcontrollers

1339 Views, 4 Favorites, 0 Comments

Battery Capacity Measurement Using Kitronik Inventor's Kit and Adafruit CLUE

clue-bt-capacity-test-energizer-cr2032-3a-65.JPG

This project shows how to use the Kitronik Inventor's Kit to make a simple battery tester which discharges a battery using a constant current load. A CircuitPython program running on an Adafruit CLUE actively controls the current and outputs data to the serial console during the discharge. The data can be used to determine the capacity of a battery in mAh and to plot the battery's voltage as the battery discharges. The circuit is designed for batteries below 6.6V.

The circuit is constructed using just the components from the Kitronik Inventor's Kit plus an additional battery holder and two cables to connect the holder. The limitations of inexpensive breadboards and the behaviour of the BC337 NPN bipolar junction transistor (BJT) are covered in detail in this article. A superior circuit could be designed but it's an interesting challenge to work within the limitations of this small set of general components.

A future article will cover adding a battery test feature as an enhancement to the program. This will show the level of the battery from a quick test.

The program could be converted to MicroPython to run on the BBC micro:bit v2 with minor simplification and on the memory-constrained v1 with major simplification.

The capacity of rechargeable batteries, accurately gauging the level and understanding the degradation with use are important areas particularly with the re-emergence of electric vehicles, the growth of short-term storage for renewable electricity generators and the abundance of battery-powered consumer electronics.

Note: the CR2032 testing in this article is at a rather high continuous 5.2 milliamps. This is not representative of typical uses of CR2032 batteries and the results should be viewed with some caution in terms of "which is best". Impatient testing at overly high currents appears to produce misleading performance variations for coin (button) cells.

Update: this tester has seen some further use, looking at AAA battery capacity in NiMH Rechargeable Battery Comparison Using Kitronik Inventor's Kit and Adafruit CLUE.

Supplies

  • Kitronik Inventor's Kit for BBC micro:bit: Kitronik | Digi-Key - there are some variants of this, a (MakeCode) Python version which just has a different booklet, and various translated booklets.
  • Adafruit CLUE: Kitronik | Digi-Key
  • Connecting leads
  • Small Alligator (Crocodile) Clip to Male Jumper Wire Bundle: Adafruit
  • or IC Hook with pigtail: Pimoroni | Digi-Key
  • or cut some Alligator (Crocodile) Clip leads in half.
  • Battery holders
  • Electro-Fashion sewable coin cell holder (for CR2032): Kitronik | Digi-Key
  • Single AA holder
  • Single AAA holder

Installing CircuitPython and Battery Tester Program

circuitpython-clue-battery-tester-v1.0-circuitpy-fs.png

If you are not familiar with CircuitPython then it's worth reading the Welcome to CircuitPython guide first.

  1. Install the latest version of CircuitPython (8.0.5 on April 2023) from https://circuitpython.org/ - this process is described in CircuitPython for Adafruit CLUE.
  2. Verify the installation by connecting to the seial console over USB. The REPL prompt shows the version number. The version can also be checked by inspecting the boot_out.txt file on the CIRCUITPY drive.
  3. Install this library from a recent bundle from https://circuitpython.org/libraries into the lib directory on CIRCUITPY:
  4. neopixel.mpy
  5. Download the example program to CIRCUITPY by clicking Save link as... on clue-battery-tester.py
  6. Rename or delete any existing code.py file on CIRCUITPY, then rename the clue-battery-tester.py to code.py. This file is run when the CircuitPython interpreter starts or reloads.

The versions used for this article were:

  • CircuitPython: 8.0.5
  • CircuitPython library bundle: adafruit-circuitpython-bundle-8.x-mpy-20230426

Setting Up the Circuit on a Breadboard

breadboard-overhead-1-65.JPG
clue-batterytester-v3_bb-65.png

A photograph and diagram of the breadboard can be seen above. The schematic is shown as a circuit simulation in steps further down.

The connectivity from the Adafruit CLUE based on the pin numbers shown on the Kitronik edge connector adapter are:

  • pin 4 ADC input (yellow) to middle of 10k+10k potential divider (voltage divider) measuring one side (transistor collector) of the load resistor pair (two 47ohm in parallel) on upper row 13.
  • pin 10 ADC input (white) to middle of another 10k+10k potential divider measuring the other side (battery positive) of the load resistor pair (two 47ohm in parallel) on lower row 28.
  • pin 12 PWM output (orange) to base resistor pair (two 2.2k in parallel) on lower row 16.
  • 0V (black) to lower (pale blue) ground (-) rail.
  • 0V (brown - black would normally be used but kit only has one M-F black) second ground going to resistor's emitter on lower row 23.

These are not in numerical order along the row of pins.

Take care with the leads on the electrolytic capacitor and BC337-25 transistor. The capacitor has the negative terminal marked, this goes to the breadboard's ground (-) rail.

It would be clearer to use black wires for all of the ground connections but the Kitronik kit only includes one colour for each type, hence the unusual use of brown and green substituting for black.

The photograph features a few extra components which will be used in a future project.

If no battery is connected then the two inputs will read 0V. If a battery is connected but the microcontroller is powered off or the program isn't running then both inputs will read the battery voltage. The battery has a 10k load when the transistor is off due to the potential dividers.

The left button (marked A) on the CLUE starts the test.

Do not leave batteries connected permanently to the circuit as it will (very slowly) flatten them.

Brief Circuit Explanation

bt-fcs-2.8-startup-combo-v2.gif

The circuit is designed to allow a battery to be safely tested with a current controlled by the microcontroller over time. The Adafruit CLUE uses the nRF52840 processor part of the Nordic nRF52 series of microcontrollers. These do not include digital-to-analogue (DAC) outputs so a pulse-width modulation (PWM) output is used as substitute to control the transistor.

  1. pin 12 produces the PWM voltage output which is smoothed by the capacitor, the resistors limit and allow the current (Ib) to be controlled through the base of the transistor.
  2. the pair of load resistors connected between the battery and the transistor's collector serve two purposes:
  3. provides an upper safe limit on the current through the transistor and
  4. allows the current to be measured from the voltage difference (drop).
  5. pin 10 and pin 4 are ADC inputs measuring the voltage either side of the load resistor pair. A pair of potential dividers halve the voltage permitting measurements up to 2 * 3.3V = 6.6V. This is sufficient for all types of single cell lithium batteries.

The Kitronik kit includes a small range of passive components. For this circuit, the values of the resistors from the kit, 47 ohm, 2.2k and 10k, weren't quite optimal. Fortunately, combinations of resistors can be used in series and/or parallel to create different values to workaround this limitation. Resistor networks are explored in Instructables: Series, Parallel, Kirchhoff.

There is more detail on PWM as a substitute for true DAC outputs in Instructables: Make a Component Tester With Adafruit CLUE and Kitronik Inventor's Kit. The frequency of the PWM is intentionally set to 8kHz to get finer granularity for duty cycle values. This frequency allows for 2001 steps in duty cycle equivalent to 1.65mV resolution.

The CLUE needs to be plugged into another computer via a USB cable to power it and for data collection. It is not powered by the battery being tested.

More Detail on the Circuit

bt-fcs-2.8-startup-screengrab2.png

The image above from the Falstad circuit simulation shows the circuit near start-up time with a 4.1V battery. It has reached a current flowing from the battery of 94.1mA. The capacitor is still charging up and the battery current is climbing and will eventually reach 154.4mA.

  • Many types of lithium batteries have a voltage over 3.3V necessitating some form of reduction for measurement by the 3.3V microcontroller. A pair of 10k resistors make a useful potential divider but a higher value, say 100k**, would have been far better for reducing the wasted current. There are two useful side-effects of the potential dividers:
  • limiting any "bad" currents going to microcontroller inputs if a battery is accidentally connected the wrong way around;
  • limiting current into the microcontroller when it is powered off - this unfortunate "back powering" can happen due to the presence of ESD protection diodes - this is discussed in Stack Exchange: AVR and STM32 ARM GPIOs state when IC is unpowered - the same principle applies to Nordic nRF52 series.
  • The potential divider resistors present a load to the battery which cannot be disabled. This is problematic for doing very low current testing on small batteries like coin cells. The microcontroller's ADC input will also consume a very small amount of current which may vary with the sample rate. Using op-amps as buffers would be the next step for monitoring the voltages with predictable, very high impedance inputs.
  • It would be nice to provide a slightly higher current to the large capacitor and transistor base. Approximating the output impedance to a constant 123 ohms, a single 2.2k resistor limits this to approximately (3.3-0.7)/(2200+123) = 1.1mA. Using two 2.2k resistors in parallel reduces the resistance to 1.1k yielding a maximum current of 2.1mA. This is still a reasonable value for a GPIO output from a microcontroller. Replacing the bipolar junction transistor with a logic-level field-effect transistor (FET) would be the next step for a dramatic reduction in the current required - this would also allow a smaller capacitor to be used enabling faster slew rates.
  • The load resistance connected to the transistor's collector isn't strictly required as the transistor can control the current but it's a useful safeguard to provide an absolute limit on the current from the battery. Lithium ion batteries can supply very high currents and a small bug in the program or interruption in the code could easily leave the transistor on. A gain (hFE) of between 160 and 400 on a base current of 2.1mA is 336mA to 840mA which is just above the maximum value for the transistor and starting to get into the inappropriate range for jumper wires and a breadboard. A single 47 ohm resistor would limit the current at 1.2V (e.g. rechargeable NiMH AA) to 26mA, two 47 ohm in parallel offers a more useful upper limit of 51mA.

The relevant maxima for the TO-92 case BC337-25 transistor are

  • On Semiconductor (acquired Fairchild):
  • 800mA continuous current and
  • 625mW for power dissipation;
  • NXP:
  • 500mA continuous current and
  • 625mW for power dissipation.

The voltage across the collector emitter is small, at high currents from a 6.6V battery there would be somewhere between 0.1-0.3V dropped across the transistor therefore at 280mA there would be 84mW dissipated. The maximum power would occur when the transistor's effective collector-emitter resistance is the same as the load resistor pair, at 6.6V this would be 140mA equating to 232mW.

It's easy to forget that resistors have a maximum power rating too. This is irrelevant at low currents but a lithium ion battery at 4.2V at 170mA would dissipate (4.20V-0.150V) * 0.170 = 689mW of power through two resistors rated at 1/4 watt (250mW) each. This type of battery will drop in voltage when loaded reducing the power to, say, (3.80-0.150) * 0.155 = 566mW. That is exceeding the power rating by 13%-38% indicating some caution is still required in the software for higher voltage batteries. A resistor with a high power rating or a larger parallel array of resistors would be a useful enhancement.

The side-effect of heat dissipation from resistors is occasionally used as a feature, in Publishing Particulate Matter Sensor Data to Adafruit IO With Maker Pi Pico and ESP-01S an example of using a resistor as a tiny heater can be seen on the Omron B5W LD0101 sensor.

** An increase to 100k could be problematic as it increases the source impedance and Nordic recommend 10k maximum for the 3 microsecond sample time which CircuitPython sets under the covers. This is discussed in EmbeddedRelated: Analog-to-Digital Confusion: Pitfalls of Driving an ADC and Texas Instruments: ADC Source Impedance (Application Note SPNA088).

Circuit Simulation

bt-fcs-2.8-loop1.gif

The circuit is shown above in the Falstad circuit simulation. The transistor is a generic model with a lower gain but it should be close enough for the BC337-25. The battery is set to 3V with a resistor of 60.4 ohms representing its internal resistance. This was intended to approximate a fresh CR2032 battery but 20 ohms would be a better starting value.

The duty cycle of the 8kHz 3.3V PWM output is set to 24%. The 123 ohm resistor represents a guess at the (simplified) output impedance of the GPIO pin. The pulsing from PWM can be seen with the current fluctuating between 2.2mA and -538uA on left side of the base resistor 2.2k pair. This is smoothed to an almost constant 658mV with a flow of 110uA through the base (Ib). The majority of the 11.2mA flowing through the battery is going through the load resistor 47 ohm pair with 0.220mA going to microcontroller's ground due to the potential dividers for the two ADC inputs on the left.

The voltages shown on the ADC inputs are 1.16V and 1.03V (rounded on the display in the image above to 1.2V and 1V) representing the voltages of 2.32V and 2.06V since these are divided by two by the potential dividers. With knowledge of the load resistance of 1 / (1/47 + 1/47) = 23.5 ohms this allows the microcontroller to calculate the current as (2.32 - 2.06) / 23.5 * 1000 = 11.1mA.

The breadboard in the photographs in this article has some additional LEDs not shown in the circuit simulation - these are currently unused.

BC337 NPN Transistor Study

BC337 transistor study using Kitronik Inventor's Kit with Adafruit CLUE

The circuit is based around a BC337-25 NPN bipolar junction transistor (BJT) controlling the battery's discharge current. The circuit and transistor behaviour are interesting to explore.

A Nordic Power Profiler Kit II (PPK2) is used in the video above as a power supply to simulate a battery with its ammeter feature providing a convenient way to see and record the current throughout the test. The behaviour of the circuit and BC337-25 NPN transistor is checked by ramping the voltage applied via a resistor pair to the base of the transistor from 0 to 3.3V in steps every 4 seconds across 400 seconds.

  • 00:11 Start of linear ramp-up of resistor base voltage, starting at 0V and incrementing in 0.033V steps ending at 3.3V 400 seconds later.
  • 00:40 PPK2 current starts increasing from lower limit of 328.6uA.
  • 01:16 Base voltage sufficient to forward bias the B/E junction.
  • 03:13 PPK2 current goes above 100mA.
  • 05:56 PPK2 reaches peak current of 120.6mA.
  • 06:51 Resistor base voltage reaches 3.3V
  • 07:05 Program interrupted, pwm pin returns to being an input.
  • 07:26 Program restarted, pwm pin now active again with 0% duty cycle and level of 0V.

The steady starting current of 328.6uA is explained by the presence of potential dividers used to reduce the voltage for ADC inputs on microcontroller. The 3.3V supply across equivalent resistance of approximately 10k is 330uA, the very slight difference will be due to some combination of

  • tiny tiny voltage drop over load resistors even when the transistor is off,
  • resistor tolerances and
  • the accuracy of current measurement by the PPK2.

BC337 NPN Transistor Study

battery-tester-basesweep-v4-g1.png

The Adafruit CLUE can measure the transistor's collector current (Ic) by measuring the voltages either side of the load resistance. For example, for a pair of 47 ohm resistors in parallel this is 23.5 ohms and 1 volt across that equates to a current flowing through both resistors and across the transistor's collector-emitter pins of 1.00 / 23.5 * 1000 = 42.6mA. The emitter current (Ie) will be very slightly higher as it includes the tiny current from the base pin (Ib).

The chart looks reasonable but shows some differences in the curves. It would be tempting to attribute these to the Early effect but careful inspection shows these do not appear to be related to the voltage from the PPK2. The measurements were all done sequentially in two batches. This warrants further investigation.

BC337 NPN Transistor Study - Good Connections?

battery-tester-basesweep-v4-g2.png

Problem 1

The raw data shows the voltage measurement of the simulated battery increasing as the current draw increases, this is shown on the first chart above. For a power supply these would be expected to be flat lines and for a battery they would decrease a little due to internal resistance. The PPK2 is highly unlikely to vary the voltage like this suggesting something is amiss.

A hint at what's going on is one "lucky" base voltage sweep with the PPK2 set to 1.000V. The breadboard was moved around between tests and some manual voltage checks with a multimeter were performed. The movement and checks may have nudged a few of the connecting jumper wires.

There must have been a high resistance path to ground from the transistor's emitter for most of these initial test runs preventing the emitter from being at the microcontroller's ground voltage (0V). The PPK2 which was powered from another computer (a laptop) has an independent ground allowing its voltage to add to the raised emitter voltage. A battery would behave in the same way in this unfortunate scenario.

Inexpensive Breadboards and Jumper Wires

electroboom-transistor-youtube-charredbreadboard-65.png
ee_eng-instructables-crimping-fail1-crop-65.JPG

The grounding issue noted in the previous page was solved by adding more ground jumper wires in parallel to existing ones. It's not a perfect solution but this reduces the resistance to ground and reduces the chance of one high resistance connection causing a substantial problem.

Breadboards and thin jumper wires are great for experimentation and rapid prototyping but analogue circuitry or moderate currents (tens or hundreds of milliamps) are likely to reveal occasional issues.

  • The very low price and lack of branding of these components suggests the manufacturing materials, processes and quality assurance will not be great.
  • Digital circuits with low data rate communication are fairly robust but analogue electronics will be more vulnerable to connectivity issues. An example of this exacerbated by high impedance outputs is discovered and discussed in Adafruit Forums: External temperature sensors vs CLUE's onboard.
  • Poor crimping on connectors of jumper wires can cause confusing issues as the cable may show a normal low resistance if measured with a multimeter but wiggling/twisting the cable can cause a substantial, unpredictable rise in resistance.
  • Component leads can pick up the sticky adhesive from the paper strips they are supplied on. This gunk is worth cleaning off properly to reduce the chance it accumulates in the breadboard and causes poor connections.
  • The commonly used jumper wires have square pins that are slightly too large for these breadboards and may deform them potentially causing more connectivity issues.
  • Breadboards can have whole rows which do not work! These faults are easier to identify than intermittent poor connectivity.

Checking the resistance of isolated parts of the circuit with a multimeter can help prevent problems. The connectors on jumper wires have a small exposed metal pad which can be useful for this.

A soldered circuit with appropriate track width and wire gauge for higher currents will be more reliable than a circuit on a cheap breadboard using jumper wires. High quality battery leads/holders with low resistance are also required for more accurate results.

The images above are a breadboard abused by ElectroBoom and an example of a poor crimp from Instructables: Make a Good Dupont Pin-Crimp EVERY TIME!

BC337 NPN Transistor Study - Temperature

battery-tester-basesweep-v4-g11.png
onsemi-bc337-temperaturecoefficient-65.png

Problem 2

Temperature has an effect. This is a well-known aspect of transistor behaviour and is used in some temperature sensors like the Texas Instruments LM35. Datasheets will include a temperature coefficient for Vbe, typically between -2.5 and -1.5mV per degree Celsius. This means for a temperature increase of 20 degrees Celsius, using the first value, the voltage required to turn on (bias) the transistor reduces by 0.05V.

The On Semiconductor BC337 datasheet chart for Temperature Coefficients is shown above. This may be a different manufacturer to the BC337-25 used in this project but the values will be similar. An interesting practical study of Vbe (p-n junction) variation with temperature can be found in Element 14 Community Blog: Diodes and Bipolar Junction Transistors (BJTs) - Measuring the Temperature Coefficient.

The heating could be from two sources:

  1. internal - self-heating from dissipating power and
  2. external - in this case due to the presence of a nearby tungsten halogen desk lamp.

The latter was intentionally used at about 7.5cm (3 inches) to check this effect, this is shown in the second chart above as the warmed (red) line.

In general, thoughtful design is required when using transistors with moderate to large currents to avoid hazardous thermal runaway, a form of positive feedback with negative consequences!

Controlling the Load Current

battery-tester-basesweep-v4-g12.png

The chart above shows the collector current (Ic) calculated by the Adafruit CLUE from its two voltage measurements and the voltage applied to the base resistor in the circuit. The base-emitter's silicon p-n junction behaves like a diode and not much happens until about 0.6V. At just over 0.7V the Ic current rises in a more-or-less straight line as the voltage increases. The base current (Ib) will be proportional to the voltage above this value. The current peaks at 117mA with the load resistor capping the absolute maximum at 3.00V / 23.5 ohms = 128mA. The current gain of the circuit is less than that of the transistor gain (hFE) due to the presence of the load resistors.

The very simple linear model is a line fitted to the points for multiple tests just for the straight portion of the curve. This provides a trivial formula for the program to use to determine the first estimate of the base voltage to set for the desired battery current. The value is then adjusted based on the actual measured Ic current. This is required because the manufacturing process creates widely differing gain for the same model transistor. This approach also accommodates temperature differences or changes. The adjustments take place after a few RC time constants to allow the large capacitor to charge or discharge to the desired voltage. The Ic current is monitored and the voltage is constantly re-adjusted to deal with any changes in the battery's characteristics to create the constant current load.

The program currently has a single constant current load target per battery chemistry type:

  • NiMH: load 40mA, min 1.0V. At 700mAh (AAA) C-rate 0.057.
  • Alkaline: load 40mA, min 1.0V. At 900mAh (AAA) C-rate 0.054.
  • LiButton: load 5mA, min 2.0V. At 200mAh C-rate 0.025, at 100mAh C-rate 0.05.
  • LiPo: load 100mA, min 3.4V. At 300mAh (small LiPo) C-rate 0.33.

There are two reasons to set a minimum voltage, some types of rechargeable battery are damaged by a deep discharge and most devices using batteries have a minimum (cutoff) voltage where the powered device will no longer function.

A higher current would be useful for testing NiMH and Alkaline batteries particularly ones larger than AAA size but this is limited by the choice of a pair of 47 ohm load resistors.

At the moment the program does not take into account the current "lost" to the potential dividers meaning its current calculation of the battery current is inaccurate. This creates a larger percentage error for small currents like the 5mA used for testing coin cells.

Guessing the Battery Type

The battery type is currently guessed from the unloaded* battery voltage.

def guessBattery(voltage):
  """Guess the battery type based on the unloaded voltage.
    Returns None if voltage is very low."""
  if voltage < 0.2:
    return None
  elif voltage <= 1.3:
    return "NiMH"
  elif voltage <= 1.55:
    return "Alkaline"
  elif voltage <= 3.35:
    return "LiButton"
  elif voltage <= 4.45:
    return "LiPo"
  return "UNKNOWN"

This will work reasonably well with single cells but can easily be fooled by partially discharged batteries or battery packs, e.g. 3AA batteries producing 4.5V. Most unloaded CR2032 batteries are just under 3.30V but the ones from Morrisons were just above this hence the 3.35V value in the code.

As an enhancement it would be useful to show the guess to the user and allow the type to be overridden if incorrect.

(*There is always a 10k load present.)

Battery Types

liion-early-cathodes-41467_2020_15355_Fig2_HTML-65.JPG

There are common names for batteries which are widely-used but they are not always an accurate representation of the battery chemistry. A list of popular primary (single-use, marked with *) and secondary cells (rechargeable) follows:

  • AA NiMH - Nickel/Metal Hydride typically with potassium hydroxide electrolyte.
  • AA Zinc Carbon* - zinc/manganese/manganese dioxide+carbon with ammonium or zinc chloride water-based paste electrolyte.
  • AA Alkaline* - zinc/manganese dioxide+carbon with potassium hydroxide electrolyte.
  • AA Lithium* - lithium/iron disulphide with lithium salt in organic solvent electrolyte.
  • CR2032 Lithium Coin (Button) Cell* - lithium/manganese dioxide with lithium salt in organic solvent electrolyte from the lithium metal group of batteries.
  • 18650 Lithium Ion - various compositions of lithium nickel manganese cobalt oxide (NMC) or lithium nickel cobalt aluminium oxide (NCA) / carbon with lithium hexafluorophosphate in organic solvent electrolyte. These are also available with lithium iron phosphate (LFP) which has a lower voltage. The carbon anode comes in multiple forms, "soft carbon", "hard carbon" and graphite.
  • Silver flat pack Lithium Polymer (LiPo) - these are Lithium Ion batteries with a solid polymer electrolyte.

CR2032 Lithium Coin Cells Sample

nine-cr2032-together1-65.JPG

The CR2032 coin cells (shown above) with the price per battery from 4-6 multipacks and manufacturing date is shown below for the batteries tested (in May 2023):

  1. Duracell (Mar 2023) 1.21GBP,
  2. Morrisons 0.63GBP,
  3. PoundMax 0.46GBP,
  4. Carrefour 0.90GBP (1.05EUR) ,
  5. Kodak (Aug 2022) ~0.40GBP,
  6. Energizer 1.83GBP,
  7. LiCB 0.80GBP (far cheaper if you buy 20),
  8. Maxell 0.60GBP,
  9. Excelltec ~0.25GBP.

The Energizer and supermarket brands were purchased in store, the Kodak ones from Poundland (a UK pound shop) and PoundMax and LiCB from a well-known, large, mail-order retailer. The Maxell and Excelltec batteries were bought from a street market. The Maxell batteries were an interesting find on a market stall which does not specialise in batteries. The solitary Maxell pack of five was accompanied by a random small mix of other brands and sizes of battery. The Excelltec batteries were sold by another stall in the same street market which had a reasonable stock of these suggesting regular sales. Energizer batteries can be purchased more cheaply from many places but a high reputation shop was chosen intentionally to reduce the chance of buying a counterfeit product - the battery market attracts counterfeiters.

All batteries were purchased within a month of testing although they clearly could have spent time on the shelf. Most batteries had a "best before" or "expiry" date on them of five or ten years. The Maxell batteries had an expiry date of December 2031 (ten year lifetime?) and had slightly crumpled packaging and perhaps some small mould spots on the packaging - this suggests they had been stored for sometime in a damp, non-optimal place.

All were labelled as manufactured in China with the exception of Maxell from Japan. There was a brief chemical smell as the Kodak battery was removed from its packaging - this is normal for coin cell batteries that have been on the shelf for sometime and may be more prominent with "baby secure" plastic sealing.

Coin (button) cells present a serious choking hazard and should be kept away from very small children.
These lithium cells are worse because of the chemical burns they can cause from electrolysis in the mouth/throat.
Careful disposal (via recycling) is required as the risk remains present even when the batteries are fully used.

Discharge Test Current Profile

battery-discharge-test-combo-v7-g3.png

The test interleaves periodic very short duration tests with much longer ones, the cycle consists of:

  1. quick test for 10 seconds,
  2. 30 second pause,
  3. discharge for 1 hour,
  4. 30 second pause

repeating until the battery reaches the the minimum (cutoff) voltage, in this case 2.0V. The quick tests and pauses were an attempt at examining how the battery voltage recovers when the majority of the load is briefly removed.

This aims to be a constant current test at 5mA. At the moment the code does not compensate for the additional current flowing through the potential divider resistors, hence the battery load is slightly higher, the current totals to approximately 5.2mA. All of the charts in this article take that into account.

The test duration is likely to be many hours. At 220 mAh / 5.2 mA = 42.3 hours. We should allow a conservative 50 hours for the first test to run even though the duration is likely to be far lower as CR2032 are not designed for this current level.

If you are testing batteries overnight it's worth ensuring no automated reboots (e.g. for software updates) will occur during that period on the computer collecting the data from the CLUE's serial console to avoid loss of data.
Unmounting/ejecting the CIRCUITPY drive will prevent any inadvertent filesystem activity causing a soft reboot of the CircuitPython interpreter.

Test Data Output

This is the output of the first quick test of the Carrefour CR2032 battery. The correct guess at the battery type is LiButton which selects a 5mA constant current target.

TEST 1 LiButton
(1, 'cc', 0, 259176965179447, 3.2705, 8.72748e-05, 0, '')
(1, 'cc', 1, 259177956954961, 3.26563, 0.000386555, 0, '')
(1, 'cc', 2, 259178947860719, 3.04152, 0.00841002, 0, '')
(1, 'cc', 3, 259179937194826, 3.02713, 0.00452206, 0, '')
(1, 'cc', 4, 259180926544193, 3.0663, 0.00583049, 0, '')
(1, 'cc', 5, 259181915725710, 2.9759, 0.00687283, -0.0389131, '')
(1, 'cc', 6, 259182906005862, 3.06199, 0.00413189, 0, '')
(1, 'cc', 7, 259183896270755, 2.99567, 0.00613449, 0, '')
(1, 'cc', 8, 259184887451175, 3.03035, 0.00456403, 0, '')
(1, 'cc', 9, 259185878921515, 3.01163, 0.00573293, 0, '')
(1, 'cc', 10, 259186870407108, 2.99135, 0.00496466, 0, 'test complete')
Approximate mean current over test: 4.7923 mA
Final voltage: 2.99135
Completition reason: test complete

The fields are:

  1. Test number.
  2. Test type:
  3. first letter c for quick capacity (level) test, d for discharge test;
  4. second letter c for constant current load.
  5. Integer number of seconds since start of this test, always starts at 0, unlikely but possible that it may skip seconds.
  6. The time in nanoseconds since microcontroller started.
  7. The ADC-calibrated battery voltage in volts.
  8. The current calculated in amps from the voltage drop over load resistors.
  9. The base adjustment to track target current or 0 for no change.
  10. Notes field, e.g.why the test ended.

The use of nanoseconds is due to use of time.monotonic_ns(). The reason for using this function and int type is explained in Adafruit Learn:CLUE Sensor Plotter in CircuitPython: Time in CircuitPython.

The current tracking improves after first 10-20 seconds.

Discharge Capacity Tests of Lithium Coin Cells

battery-discharge-test-combo-v9-g2.png
battery-discharge-test-carrefour1-1a-v7-g1.png
battery-discharge-test-duracell1-1a-v7-g1.png
battery-discharge-test-energizer1-4a-v7-g1.png
battery-discharge-test-excelltec1-2a-v7-g1.png
battery-discharge-test-kodak1-1a-v7-g1.png
battery-discharge-test-licb1-1a-v7-g1.png
battery-discharge-test-maxell1-1a-v7-g1.png
battery-discharge-test-morrisons1-1a-v7-g1.png
battery-discharge-test-poundmax1-1a-v7-g1.png

The charts above show discharge tests for various brands of CR2032 batteries. The individual charts show the points each second for the quick ten second tests as red crosses.

The testing was conducted in a room which varied between 20 to 22 degrees Celsius. The temperature of the battery has a significant effect on battery performance. NB: the temperature of a battery can be higher than the ambient temperature - this is likely to occur at high currents.

The Energizer CR2032 data sheet shows a capacity of 235mAh down to 2.0V. This is clearly different to the results shown above. The data sheet includes the detail which explains this. That capacity value is valid for a test with a 15k load which equates to an average discharge current of approximately 170uA.

Carrefour is a surprising leader at 147mAh (vive la difference!), the majority sit between 124mAh-107mAh, then LiCB at 96mAh and Maxell at 88mAh. The provenance and storage pre-purchase of the Maxell batteries did not appear to be good so this could explain the poor result.

The Carrefour battery has an odd-looking recovery in voltage early on and the Excelltec has a similar one much later in its discharge.

The Morrisons battery had the highest initial unloaded voltage at 3.33V.

Only one battery per brand was tested with the exception of a second LiCB (not shown). The second LiCB was very similar to the first one. A proper test would test more than one battery to check the variance across a reasonable sample of each. A thorough test would test different manufacturing batches and different factories/suppliers.

CR2032 Datasheets - Capacity and Voltage Variation With Load

energizer-licoinappman-cc-discarge-rates2-65.png
maxell-datasheetcr2032-cr-discarge-rates1-corrected-65.png

The Energizer Lithium Coin - Handbook and Application Manual is an excellent source of information on coin cell batteries including their CR2032 battery. For comparison, the Maxell CR2032 Datasheet (later 2016 version mentioning CR2032H) also has some useful charts.

The two charts above show:

  • left - the capacity variation with constant current discharge rate (0.5mA to 3.0mA) - the battery can provide over 200mAh for a 2.0mA load;
  • right - the duration variation (logarithmic scale) with constant resistance loads temperature (15k to 1M - datasheet has a typo, green 150k as 15k, corrected here).

There's a clear picture here that these small coin cells have higher/optimal capacity at very low loads.

CR2032 Datasheets - Capacity Variation With Temperature

energizer-licoinappman-cc-discarge-temp2-65.png
maxell-datasheetcr2032-cc-discarge-ratestemp1-65.png

The charts above show considerable performance degradation below room temperature:

  • left - the capacity variation with temperature (0, 21, 40 degrees Celsius);
  • right - the capacity variation with temperature (-20, -10, 10, 20, 60 degrees Celsius).

The Energizer has a ~30% drop in capacity from room temperatures to 0 degrees Celsius, the Maxwell at 1mA has a smaller ~15% drop in capacity from room to -10 but has lower capacity than the Energizer at room temperature.

CR2032 Random Capacity Variation at High Currents

toolstested-cr2032-highcurrenttests-youtube-table1.JPG

Tools Tested have tested a wide variety of CR2032 batteries available in North America to:

"determine which one is best".

The tests were performed using a Rigol DL3021 Programmable DC Electronic Load with constant current loads of 10mA to 2.7V (left table) and 25mA to 2.0V (right). These currents are far higher than the tests covered in manufacturers' datasheets and few devices will be used in a way where this continuous high current is required.

The first observation on the results is there is poor correlation in the duration and ranking between the two tests. For example, Duracell in the first test lasts 07:09 which is 35% of the best performer, Toshiba. In the second test Duracell lasts 20:47 which is 67% of best performer and puts it in 5th position outperforming Toshiba considerably.

This testing inspired the addition of LiCB batteries to the testing for this article as these results could be interpreted as providing evidence of LiCB being good performers. In the tests at 5.2mA to 2.0V shown in this article LiCB ranked 8th out of 9.

The video at 04:10 does mention the test parameters do not match many real uses:

"Now in a real life scenario most of these batteries are only going to have a small amp draw on them and sometimes that amp draw is going to be real quick like a key of course so just keep that in mind from these test results."

Discarded Lithium Ion Batteries

disaster-girl-18650s.JPG
discarded-vaper.JPG
discarded-vaper-inside.JPG

Big Clive and others have noted that disposable vapes are typically powered by lithium ion batteries. One of these colourful nicotine delivery devices is shown above, this was discarded on the pavement (sidewalk) near the author's home. These can be recycled but a short lifetime and a design prohibiting reuse are wasteful and odd given the lifetime of the constituent components.

The second photograph with the case removed shows the simple components on top of an unrelated schematic. The circuit is very simple with a pressure-activated active switch triggered by inhalation connecting the battery to a heating element. The battery is a rechargeable, single cell Lithium ion marked as a 13300 3.7V 360mAh. It does not have a battery protection circuit (a basic battery management system (BMS)) attached to it. The battery has very clear colour-coding for the terminals but the vape manufacturer has chosen to add both a black and a red wire to the negative terminal which is a little confusing.

Despite the low capacity of some of these batteries some caution and expertise is still required to reuse them safely due to their lack of connectors, battery protection circuitry, warranty and their propensity to catch fire if mistreated.

The innards of the vape may be relatively easy to access but simple actions like cutting two wires at the same time can cause a momentary short through the blade of the cutters. This will result in a huge current passing through the wires and unprotected battery. Becky Stern looks at how to reuse these batteries and covers some of the safety issues in more detail in her blog post Reusing Disposable Vape Batteries. The US Consumer Product Protection Commission has a warning on (re)using lithium ion batteries.

The 13300 battery was carefully removed and found to be at 3.71V unloaded. Some further neighbourhood de-littering yielded a 13400 550mAh at 3.60V and a chubby 20400 1500mAh at 4.05V. These were cautiously recharged using the JST-PH battery connector of an Adafruit Feather board which has a LiPo charger. After charging they all measured 4.12V. All of these voltages are unloaded. As can be seen from the discharge curves later in this article the voltage will rapidly and substantially drop when even a small load is applied.

There is no standard for the power supply pin order (polarity) on two pin JST-PH connectors. These are commonly used for battery connectors on boards from Adafruit and Pimoroni and the BBC micro:bit - these three all share the same order. Batteries and cables sold by other retailers may have different pin orders. Take care with the polarity and maintain the red (positive) and black (negative) colour-coding.

First Discharge Capacity Test of Discarded Lithium Ion Batteries

battery-discharge-test-combo-v9-g6.png
battery-discharge-test-vape13300-2-2a-v8-g5.png
battery-discharge-test-vape13400-1-1a-v8-g5.png
battery-discharge-test-vape20400-1-1a-v8-g5.png

The charts above show discharge tests for the three sizes of lithium ion batteries carefully recovered from discarded, disposable vapes. The testing was conducted in a room which varied between 20 to 22 degrees Celsius. The minimum voltage of 3.4V means the test stops a little bit before the "knee" of the curve where there's a dramatic fall in the battery voltage.

The constant current test with a target current of 100mA appears to be the same for all three batteries but the discharge rate relative to the capacity of battery is greater for smaller batteries and this has an effect on the discharge curve. Using the claimed capacity printed on the batteries, the C-rate (not to be confused with coulombs) for each test is:

  1. 13300 360mAh 0.28C discharge rate,
  2. 13400 550mAh 0.18C,
  3. 20400 1500mAh 0.067C.

The claimed capacity is likely to be based on a C-rate and a minimum voltage. The observed capacity to 3.4V was (percentage of claimed capacity in brackets):

  1. 13300 213mAh (59%),
  2. 13400 378mAh (69%),
  3. 20400 834mAh (56%).

Now that the circuit, this implementation of it and the v1.1 software has proved itself to work correctly this test could be re-run with a slightly lower voltage to plot the knee and better gauge the capacity.

UPDATE: these were re-tested, second set of results are shown lower down.

Minimum Voltage for Lithium Ion / LiPo Batteries

sony-graphite-18650-capacity-dischargecurve-withload1.png
sony-liion-handbook-operatingvoltages-65.png

The start of the voltage drop (knee) is visible on the discharge charts above for the Sony UP383562.

The Sony: Lithium Ion Rechargeable Batteries Technical Handbook specifies the minimum voltage as:

  • 3.0V for a Sony Polymer (UP383562) and Sony US18650GR batteries with graphite anodes, nominal voltage 3.7V;
  • 2.5V for a Sony US18650 with a carbon anode, nominal voltage 3.6V.

Allowing for some error in the measurement, a minimum voltage of 3.05V for testing is a conservative choice if no further information is available from a reputable retailer or the battery manufacturer.

Murata Manufacturing purchased Sony's battery division in 2016.

Discharge Capacity Test of LiPo Batteries

battery-discharge-test-combo-v9-g8.png
battery-discharge-test-combo-v9-g9.png
battery-discharge-test-eunicell-b1-3a-v9-g7.png
battery-discharge-test-eunicell-b2-2a-v9-g7.png
battery-discharge-test-eunicell-b3-2a-v9-g7.png
battery-discharge-test-eunicell-b4-2a-v9-g7.png
battery-discharge-test-eunicell-b5-2a-v9-g7.png
battery-discharge-test-eunicell-b6-2a-v9-g7.png

The charts above show discharge tests for the two sizes of Eunicell flatpack lithium polymer (LiPo) ion batteries purchased from Kitronik. Two batteries, one of each size, are about 3 years old and have been used 10-20 times, the other four are unused. The testing was conducted in a room which varied between 23 to 25 degrees Celsius. The minimum voltage of 3.05V covers the "knee" section. The datasheet for these batteries (400mAh, 1000mAh) states:

End Voltage of Discharge 3.0V
400mAh Over Discharge Detect Voltage 2.85V 3.0V 3.1V [probably minimum, typical, maximum]
1000mAh Over-discharge detect voltage 2.3V 2.4V 2.5V (min., typ., max.)

The constant current test with a target current of 100mA gives a discharge rate of:

  1. 502535 400mAh (440mAh in datasheet!) 0.24C discharge rate,
  2. 523450 1000mAh (1050mAh in datasheet) 0.1C.

The claimed capacity is very similar to the test results and there's good consistency between the batteries despite varying age.

| Lithium Polymer batteries are not robust and need an enclosure to protect them.

Second Discharge Capacity Test of Discarded Lithium Ion Batteries

battery-discharge-test-combo-v10-g11.png
battery-discharge-test-vape13300-2-3a-v10-g10.png
battery-discharge-test-vape13400-1-2a-v10-g10.png
battery-discharge-test-vape20400-1-2a-v10-g10.png

Some wire or component wiggling before the LiPo testing causing a voltage jump in the measured values suggesting there was another high resistance path causing a problem. This retest of the discarded lithium ion batteries shows some higher initial voltages. This test was terminated at 3.05V which gets closer to the cut-off voltage for the full capacity.

The observed capacity for this second test to a lower 3.05V was (percentage of claimed capacity in brackets):

  1. 13300 318mAh (88%),
  2. 13400 453mAh (82%),
  3. 20400 1354mAh (90%).

There could be some differences here due to the charging process which is important for batteries but the main conclusion is that accurate, reliable and consistent results for this type of circuit are hard to achieve on a breadboard with thin wires and questionable connectors.

A power profiler like the Nordic PPK2 could be left in series to both verify the accuracy of the constant current load and to more accurately count the charge in coulombs (3600C = 1000mAh) over time.

Going Further

Elwell-Parker-EV-1895.jpg
McLarenArtura-7-crop65.JPG

An Elwell-Parker electric vehicle (lead acid battery pack) from 1895 and a McLaren Artuara hybrid vehicle (lithium ion battery pack) from 2023 are shown above.

After you have done some battery capacity testing, here's some ideas for areas to explore:

  • Fix the code to accommodate the current "lost" to the potential dividers as its current calculations are flawed and current values will be lower than the real draw from the battery being tested.
  • Perform long duration tests on CR2032 at more realistic low loads, say, 2.5mA and 1mA. It's worth verifying that the tester is capable of performing low current tests.
  • Test multiple batteries of the same type to check the consistency. Test multiple batteries of the same type including ones from questionable retailers to look for lower performance from possible counterfeits.
  • Enhance the program to allow the battery type to be overridden/specified.
  • Check other battery types like lead acid or zinc air (staying below the 6.6V voltage maximum).
  • Check capacity at different temperatures.
  • Additional test load types could be added, like
  • constant resistance (a passive load) and
  • constant power (representing switched mode power).
  • Further test types could be created by varying the battery use over time, i.e.non-continuous, pulsed workloads of the three constant load types.
  • Measure current use over time for a real device to create a benchmark test which accurately represents it.
  • Plot and compare ampere-hour (a charge measurement) vs watt-hour (an energy measurement) data.
  • Use two extra ADC inputs on the microcontroller to measure the voltage either side of the base resistor to determine the base current more accurately. This would allow creation of reasonably accurate Gummel plots.
  • Convert to MicroPython for BBC micro:bit v1 or v2 or tweak CircuitPython code to run on v2.
  • Use the CLUE's display for something useful:
  • guessed/selected battery type,
  • battery voltage and current,
  • plot voltage over time as battery discharges.
  • Create a battery tester to show the level/health of a battery. This will be covered in a subsequent article.
  • Improve the circuit as discussed in the article and/or move to a soldered implementation.
  • Duplicate the circuit keeping the original with a larger load resistance to allow accurate testing of low currents, i.e. the original transistor could handle 1-100mA and the second sub 1mA. Both could be used to provide higher resolution/finer control of the current.

Related projects:

Further reading: