DIY Smart Multipurpose Battery Tester

by opengreenenergy in Circuits > Arduino

9500 Views, 140 Favorites, 0 Comments

DIY Smart Multipurpose Battery Tester

123.png
thumbnail1.png
DSC00238.png
oshw_Certificate.jpg
DIY Smart Multipurpose Battery Tester || Battery Capacity Tester

In recent years, the market has been flooded with low-cost batteries, many of which originate from unregulated manufacturers. A significant concern with these batteries, is the inaccurate labeling of capacity. Often, these batteries claim to have high capacities sometimes exceeding 10,000mAh at prices that seem too good to be true. In reality, many of these batteries fall far short of their advertised capacity, providing poor performance and posing potential safety risks due to overcharging or overheating.

For consumers and hobbyists who rely on batteries for DIY projects, RC models, portable electronics, or even solar power setups, it is essential to ensure that the batteries they purchase live up to their promised specifications. Unfortunately, distinguishing between a high-quality battery and a low-grade, falsely advertised one isn't always possible by appearance alone.

This is where our device DIY Smart Multipurpose Battery Tester becomes crucial. It allows users to verify the capacity of the batteries they purchase, helping them avoid the pitfalls of using fake or low-quality batteries.

Earlier, I developed the Battery Capacity Tester V2.0, which was designed primarily for discharging batteries to measure their capacity. However, it lacked some essential features, encouraged the development of an upgraded version.

👉 My Book : DIY Off-Grid Solar Power for Everyone

You can order my Book on Off-Grid Solar Power from Amazon

  1. eBook
  2. Paperback - Black & White
  3. Paperback - Color Print


What is New in the New Version?

The earlier version was designed solely to discharge the battery for capacity testing. However, in this version, users can both charge and discharge the battery, effectively turning the device into a battery charger as well.

The following are the major upgraded features compared to V2.0:

1. XIAO ESP32 Microcontroller:

The new version uses the XIAO ESP32 instead of the Arduino, providing a smaller footprint while adding WiFi capabilities. This allows for remote monitoring and control, enabling users to track battery testing results from anywhere.

2. Integrated Charger Circuit:

Unlike the V2.0, which required an external charger to fully charge the battery before testing, the new version features an integrated charging circuit. This allows users to charge and test batteries in one go, making the process more streamlined and convenient.

3. Compact SMD Current Sense Resistor:

This version replaces the bulky ceramic resistors used in V2.0 with a compact SMD current sense resistor. This not only saves space but also improves efficiency by reducing heat buildup, making the tester more compact and easier to handle.

4. Onboard Battery Holder:

It includes a 18650 battery holder directly mounted on the PCB. This enhancement removes the need to connect batteries externally through screw terminals, which was the case with the V2.0 model. Now, users can simply insert their 18650 battery into the onboard holder for quick testing. Additionally, a JST connector is provided for connecting LiPo batteries or other battery sizes that don’t fit the 18650 holder, offering more flexibility in the types of batteries that can be tested.

5. Firmware Upgradtion:

The current firmware now supports four modes:

  1. Charge Mode: Direct battery charging with the built-in charger circuit.
  2. Discharge Mode: Continuation of V2.0’s battery capacity testing by discharging.
  3. Analyze Mode: Automatically charges, pauses, and discharges to measure true battery capacity.
  4. IR Test Mode: Measures the internal resistance of the battery condition evaluation.

6. Cutoff Voltage Setting: Users can now set the discharge cutoff voltage using push buttons and the OLED display, eliminating the need to modify and re-upload code.

Supplies

DSC00053.png
DSC00042.png

PCB:

PCB ( PCBWay )

Components:

1. Battery Capacity Tester PCB V3.0 ( PCBWay )

2. LP4060 Battery Charger IC (U1) - 1 ( Aliexpress / LCSC )

3. AP6685 Protection IC (U2) - 1 ( LCSC )

4. XC6206P332MR LDO (U3) - 1 ( Amazon )

5. XIAO ESP32C3 Microcontroller (U4) - 1 ( Amazon )

6. LMV321B-OpAmp (U5) - 1 ( Amazon )

7. LM385-1.2 Voltage Reference (U6) - 1 ( LCSC )

8. OLED Display 0.96 INCH 128X64 I2C (DSP) - 1 ( Amazon )

9. Buzzer (BZ) - 1 ( Amzon / LCSC )

10. Capacitor 10uF (C1, C2, C4, C5) - 4 ( Amazon )

11. Capacitor 100nF (C3,C6, C7, C8, C9, C10, C11, C12) - 8 ( Amazon )

12.. Resistor 1kΩ (R3, R4, R7, R9, R13) - 5 ( Amazon )

13. Resistor 2kΩ (R8) - 1 ( Amazon )

14. Resistor 4.7kΩ (R18, R19, R20) - 3 ( Amazon )

15. Resistor 5.1kΩ (R1, R2, R6) - 3 ( Amazon )

16. Resistor 10kΩ (R5,R12, R14) - 3 ( Amazon )

17. Resistor 33kΩ (R11) - 1 ( Amazon )

18. Resistor 100kΩ (R17) - 1 ( Amazon )

19. Resistor 200kΩ (R16) - 1 ( Amazon )

20. Resistor 100mΩ/1W (R15) - 1 ( Amazon / LCSC )

21. P-Channel MOSFET AO3401A (Q1) - 1 ( Amazon / LCSC )

22. NPN Transistor 2N3904S (Q2) - 1 ( Amazon / LCSC )

23. N-Channel MOSFET IRL540 (Q3) - 1 ( Amazon / LCSC )

24. Diode SS34 (D1, D2) - 2 ( Amazon )

25. LED-0805 Red (LED) - 1 ( Amazon )

26. Push Buttons (UP/DOWN) - 2 ( Amazon )

27. Slide Switch (PWR) - 1 ( Amazon )

28. JST Connector (BAT) - 1 ( LCSC )

29. Battery Holder (BT) - 1 ( Amazon / LCSC )

30. TYPE-C Connector (USB) - 1 ( Amazon / LCSC )

31. Heatsink (HS) - 1 ( Amazon / LCSC )


Tools Used:

1. Soldering Iron ( Amazon )

2. Hot Plate ( Amazon )

3. 3D Printer ( Amazon )

How It Works

Sheet_1.jpg
DSC00045.jpg
pin_map-2.png

The device working is broadly divided into the followings:

1. Microcontroller (XIAO ESP32C3)

The XIAO ESP32C3 serves as the brain for the device. It manages the overall operation by reading input from the user through buttons, processing the voltage and current measurements. It also communicates with the OLED display to show real-time data.

2. Charging Circuit

The LP4060 Battery Charger IC is used to charge the connected battery. The XIAO ESP32C3 controls the charging process through the MOSFET (Q1). When charging mode is activated, the MOSFET switches on, allowing current to flow through the battery from the charging circuit.

  1. The charger operates in constant current and constant voltage modes, ensuring a safe charging process.
  2. The SS34 Schottky Diodes (D1, D2) protect the circuit from reverse voltage.

3. Constant Current Load Circuit / Discharging Circuit

In this unity follower circuit, the op-amp output follows the input (reference voltage) to control the current flow through the MOSFET and the shunt resistor.

By adjusting the PWM input, the user can set the discharge current, which the op-amp maintains through the feedback loop, ensuring consistent current flow for capacity measurement. As per Ohm's Law (V = IR), the voltage across the current-sense resistor corresponds to the current flowing through it.

4. Voltage and Current Measurement

Battery voltage measurement is done using a voltage divider to bring the battery voltage down to a measurable range for the ADC. Current measurement is performed using a low-value current sense resistor and monitoring the voltage drop across it.

5. Display and User Interface

The OLED Display provides a user-friendly interface for controlling and monitoring the tester. The user can select different modes (charge, discharge, analyze), set cutoff voltages, and monitor real-time data such as voltage, current, capacity, and time elapsed.

7. Power Supply

The device is powered through a Type-C connector (USB), which provides the necessary power for the microcontroller and charging circuit. The 5V USB is stepdown to 3.3V by using LDO U3. The power switch (PWR) close the circuit to power the device.

Charging Circuit

Sheet_2.jpg

Charging Circuit:

It is built around the IC LP4060 (U1) , which provides a constant-current/constant-voltage charging mechanism, ideal for single-cell lithium-ion batteries. The circuit requires minimal external components like resistors and capacitors. The circuit is based on the application circuit given in the datasheet.

Battery Protection Circuit:

The battery protection circuit ensures the safety of the Li-Ion battery during operation. It uses the IC AP6685 (U2), which includes an internal power MOSFET, voltage detection circuits, and delay circuits to provide multiple protections. These protections include reverse polarity protection, overcharge protection, over-discharge protection, and load short-circuit protection. This ensures that the battery remains safe from damage during charging, discharging, or accidental misuse.

Discharging Circuit

Sheet_3.jpg

The discharging circuit is designed as a constant current load. It uses an operational amplifier (U5) a PWM signal, a current sense resistor (R15), and a MOSFET (Q3) to regulate the current drawn from the battery.

The PWM signal generated by the XIAO ESP32C3 (U3) is filtered through a resistor and capacitor network to produce an equivalent analog voltage. This filtered voltage is fed to the non-inverting input of the op-amp, which acts as a unity-gain follower. The inverting input of the op-amp is connected to the voltage across the current sense resistor (R15), which is in series with the MOSFET’s source pin.

The op-amp continuously adjusts the gate of the MOSFET (Q3) to regulate the current flowing through the resistor based on the voltage set by the PWM signal. As per Ohm's law, the current is controlled by maintaining a constant voltage across the sense resistor. This creates a stable, adjustable load that discharges the battery at a set current, allowing precise capacity measurement.

OLED Display

DSC00138.jpg
Sheet_4.jpg
DSC00099.png

The OLED is connected to the XIAO ESP32C3 microcontroller via the I2C communication protocol, which uses two pins: SDA (Data Line) and SCL (Clock Line). The I2C address for the OLED is typically 0x3C, which is used to communicate between the microcontroller and the display.

Hardware Setup:

The hardware connections should be as follows:

  1. SDA : Connected to the XIAO SDA pin (Pin 21)
  2. SCL : Connected to the XIAO SCL pin (Pin 22)
  3. VCC: Connected to the 3.3V pin on the XIAO ESP32C3
  4. GND: Connected to the GND pin on the XIAO ESP32C3

Breadboard Testing

DSC00135.png
DSC00136.png

First I made the circuit on a breadboard to test its functionality. This allowed me to verify the correct operation of all components, including the MOSFET, buttons, display, and other elements. I carefully observed the circuit’s behavior during charging and discharging modes to ensure everything functioned as intended. Once the breadboard prototype worked as expected, I proceeded to design the PCB.

Designing the PCB

3D PCB.png
PCB_Top.png
PCB_Bottom.png
DSC00048.png

After successfully designing the prototype PCB, I placed an order with PCBWay, and to my delight, they delivered it to my doorstep within a week. The black PCB with immersion gold finish looked fantastic, giving it a professional and polished appearance. Along with the PCB, I also ordered a stencil, which proved to be a smart choice for improving the assembly process.

The use of a stencil offers several advantages. It significantly cuts down the time required for applying solder paste, ensuring that the right amount is evenly distributed across all the pads. This not only speeds up the assembly process but also minimizes the chances of errors such as bridging or insufficient solder on pads. The precision of the stencil ensures that components are correctly placed and soldered, making the entire process more efficient and reducing the likelihood of rework.

Once I had everything in hand, I moved on to assemble the PCB using the stencil.

👉 Order the PCB or Download the Gerber files from PCBWay

Aligning the Stencil

DSC09995.png
DSC00002.png
DSC00006.png
DSC00017.jpg
DSC00020.png

Place the PCB on a flat surface to ensure it stays level during the process.

Surround the PCB with four additional PCBs to help secure the main PCB in place. These additional PCBs act as supports to prevent any movement.

Use masking tape to secure the four surrounding PCBs to the surface, ensuring everything remains intact.

Carefully align the stencil on top of the PCB, ensuring that the stencil is perfectly aligned with the SMD pads where the components will be placed.

Secure the edges of the stencil with masking tape to prevent any movement during the application of solder paste.

Applying Solder Paste

DSC00027.jpg
DSC00028.jpg
DSC00030.png

Once the stencil is properly aligned, apply a small amount of solder paste to the top of the stencil.

Using a spatula or credit card, spread the solder paste evenly across the stencil. Be sure to cover all the cutout areas where the components will sit.

Scrape off any excess solder paste and ensure that the paste is applied only to the exposed pads.

Carefully lift the stencil off the PCB, leaving solder paste on the SMD pads.

Placing Components

DSC00059.png
DSC00061.png

Using tweezers, pick up each component one by one as per the schematic.

Place each component onto the corresponding SMD pads on the PCB, which now have solder paste applied. Ensure correct orientation for polarized components like diodes, and LED.

Continue this process until all components are placed on the PCB as per the design.

Reflow Soldering

DSC00072.png
DSC00070.png
DSC00080.png

Once all components are in place, carefully transfer the PCB onto a heat plate or into a reflow oven. Set the temperature according to the solder paste manufacturer's instructions (typically between 220°C and 240°C).I have used my Miniware MHP50 hotplate to solder the components.

Allow the heat plate or oven to heat up and cook the PCB. As the solder paste melts, the components will automatically align themselves to the pads.

After the soldering process is complete, remove the PCB from the heat plate to prevent overheating, which could damage the components.

Allow the PCB to cool down naturally. Once cool, clean the PCB with isopropyl alcohol (IPA) to remove any residual flux or paste.

Inspect the PCB

DSC00195.png
2020_0102_014234_006.jpg
2020_0102_014252_006.jpg

After the PCB has cooled, carefully inspect it to ensure all components are properly soldered.

Use a magnifying glass or microscope to check for any cold joints, misaligned components, or solder bridges.

If you notice any issues, such as incomplete connections or excess solder, perform touch-up soldering using a soldering iron to fix these problems.

Ensure that each component is correctly positioned and securely soldered to avoid functionality issues later

Install the Through Hole Components

DSC00109.jpg
DSC00085.png
DSC00096.png
DSC00124.png

After soldering all the SMD components, the next step is to solder the through-hole (TH) components like: switch, buzzer, MOSFET, heatsink, and female header pins for the OLED display.

First solder the switch,

Start by inserting these components into their respective positions on the PCB, bending the leads slightly to keep them secure.

Switch: Solder the leads of the switch

Buzzer: Solder the buzzer leads firmly to ensure a stable connection, the pitch of the buzzer pin is 5mm and diameter is 9mm. Unfortunately, I purchased a wrong size, buzzer.

Female Header Pins: Strip out 4 pins from the female header strip and solder the header to the PCB, ensuring proper alignment.

MOSFET: Attach the MOSFET to the heatsink. Apply a thin layer of heatsink compound to the MOSFET to improve thermal conductivity, and secure the MOSFET to the heatsink using a screw to ensure it is tightly fastened. This will help in dissipating heat effectively. Thhen, solder the MOSFET and heatsink legs to the PCB. When soldering the MOSFET, ensure that the leads are properly connected to handle high current.

Install the PCB Standoffs

DSC00091.jpg
DSC00108.png
DSC00089.png

After completing the assembly of all the components on the PCB, I moved on to installing the M3 brass hex standoffs to the PCB mounting holes. These standoffs are crucial for providing support and elevating the PCB from the ground/enclosure, preventing any contact with the surface below that could cause short circuits or damage to sensitive components.

Following steps may be used to install:

  1. Place an M3 screw through the PCB mounting hole from the top side of the PCB.
  2. Thread the brass hex standoff onto the screw from the bottom side of the PCB.
  3. Tighten the standoff using a screwdriver for the screw and hand-tighten.

3D Printed Enclosure

DSC00342.jpg
DSC00347.png
Screenshot 2024-10-16 211146.jpg
Screenshot 2024-10-16 211215.jpg
Screenshot 2024-10-16 211648.jpg

To protect the PCB and give it a professional look, I designed a custom enclosure using Autodesk Fusion 360. The enclosure consists of three parts:

  1. Cover
  2. Housing
  3. 3 x Buttons

The Bottom Body doesn’t require any support structure for printing, making it straightforward. However, the Cover and Buttons does need a support structure to ensure a proper print.

Install the PCB Into the Housing

DSC00305.png
DSC00295.jpg
DSC00288.png
DSC00291.png
DSC00355.png
DSC00353.png
DSC00349.png
DSC00368.png

I am excited to share that all three arts ( housing, cover, and buttons ) have been successfully 3D printed, taking a total of around 7 hours. The outcomes can be viewed in the pictures above.

For installating of the PCB into the housing, I opted for 4mm heat inserts and used a soldering iron tip to carefully press these inserts into the standoffs of the housing. I then aligned the PCB mounting holes with these heat inserts and fastened the PCB in place using M3 screws.

Next, I inserted the three buttons into their respective holes as shown in the picture above and secured the cover onto the housing using a snap-fit mechanism.

After assembling, I noticed that the alignment of the USB-C port was not perfect. I believe this issue stemmed from the 3D PCB model used in my Fusion design being thinner than the actual manufactured PCB. I will fix this in the design soon.

Update On 21.10.2024

I have corrected the design files and updated STL files are attached for downloading.

Software & Libraries

Screenshot 2024-10-05 130924.png
Screenshot 2024-10-05 130511.png
Screenshot 2024-10-05 130633.png
Screenshot 2024-10-05 130721.png

The software of the Tester manages operations, including charging, discharging, and analyzing battery performance. It runs on the XIAO ESP32C3.

Libraries Used:

  1. Adafruit GFX
  2. Adafruit SSD1306
  3. JC_Button
  4. Wire

Setup and Programming:

Open Arduino IDE.

Go to Sketch -> Include Library -> Manage Libraries.

In the Library Manager window, search for and install the following libraries:

  1. Adafruit GFX Library
  2. Adafruit SSD1306 (for the OLED display)
  3. JC_Button (for button handling)

Connect the XIAO ESP32C3 to your computer using a USB cable.

Select the appropriate Board by going to Tools -> Board -> Select your device (XIAO ESP32C3).

Select the correct Port by going to Tools -> Port and choosing the port your device is connected to.

Click the Upload button (arrow icon) in the top-left corner of the Arduino IDE.

Wait for the sketch to compile and upload to the device.

Once the upload is complete, the IDE will display the message "Done uploading."

How to Use the Device

DSC00241.png
DSC00138.jpg
DSC00140.png
DSC00190.jpg
DSC00149.png
DSC00150.png

Powering the Device: Connect the device to a power source using the USB cable. The maximum USB voltage is 5V.

Connecting the Battery: Attach the battery you wish to test or charge to the 18650 battery holder or BAT connector, ensuring proper polarity (positive to positive and negative to negative).

The device has four operational modes: Charge, Discharge, Analyze, and Internal Resistance (IR) Test. The Mode button, along with the UP and DOWN buttons, are used to navigate and select these modes.

Selecting a Mode:

Once the battery is connected, press the Mode button to cycle through the modes.

Use the UP and DOWN buttons to scroll through the options.

The available modes will be displayed on the OLED screen:

  1. Charge Mode
  2. Discharge Mode
  3. Analyze Mode
  4. IR Test Mode

When the desired mode is highlighted, press the Mode button again to confirm your selection. The long beep confirm that the mode is selected.

A. Charge Mode: To charge the battery safely to full capacity.

  1. Select Charge Mode from the menu.
  2. The device will automatically start charging the battery, activating the MOSFET to connect the charger.
  3. The OLED will display the charging status, showing time elapsed, battery voltage, and the selected mode.
  4. The charging will stop automatically when the battery voltage reaches 4.18V, and a completion message will be displayed.

B. Discharge Mode:To safely discharge the battery to a specified cutoff voltage.

  1. Select Discharge Mode from the menu.
  2. Use the UP and DOWN buttons to select the discharge current.
  3. The device will discharge the battery by activating the PWM-controlled load.
  4. The LCD will show the time elapsed, battery voltage, and the total discharged capacity (in mAh).
  5. Discharging will stop automatically once the battery reaches the selected cutoff voltage.
  6. Final discharged capacity is displayed on OLED

C. Analyze Mode: To determine the true capacity of the battery through a full charge-discharge cycle

  1. Select Analyze Mode from the menu.
  2. The device will first charge the battery to 4.18V.
  3. After charging, it will rest for 5 minutes to let the battery stabilize.
  4. It will then discharge the battery to measure the true capacity.
  5. The OLED will display the charging status, resting phase, and discharge progress.
  6. The battery’s true capacity (in mAh) is displayed after the complete cycle.

D. IR Test Mode (Internal Resistance Test): To measure the internal resistance (IR) of the battery.

  1. Select IR Test Mode from the menu.
  2. The device will measure the battery voltage with no load (open-circuit voltage).
  3. It will then apply a load using PWM control and measure the voltage under load.
  4. The device calculates the internal resistance using Ohm’s Law:
  5. 𝑅 = ( 𝑉𝑛𝑜𝑙𝑜𝑎𝑑 −𝑉𝑙𝑜𝑎𝑑) / R
  6. where I is the current set by the user using the UP and DOWN buttons.
  7. The IR value will be displayed on the OLED in milliohms (mΩ).

WARNING : Safety Precautions

  1. Ensure that only the correct battery type is used; this version is designed specifically for lithium-ion batteries ( 3.7V and full charge voltage 4.2V)
  2. Avoid touching the heatsink during the discharging process, as it can become extremely hot and may cause burns.
  3. Always monitor the device closely while charging or discharging batteries to prevent any potential issues.
  4. Immediately disconnect the battery if any abnormal behavior is observed, such as excessive overheating or unusual sounds.

IR Test

DSC00249.png
DSC00210.png

The Internal Resistance (IR) of a lithium-ion battery refers to the resistance within the battery that opposes the flow of electric current. It is an important parameter that impacts the battery’s efficiency, performance, and heat generation during operation.

Why is IR Important ?

Voltage Drop: When current flows through a battery with internal resistance, there is a voltage drop across the battery’s terminals, which means the available voltage is reduced. The higher the current draw, the greater this voltage drop.

Heat Generation: Internal resistance causes heat buildup in the battery during discharge or charge cycles, especially at higher currents. Excessive heat can degrade the battery over time.

Efficiency: A battery with a lower IR operates more efficiently because less energy is wasted as heat.

What is the Typical Value of IR for 18650 Batteries?

  1. New or High-Quality 18650 Cells: Typically have an internal resistance of 15 mΩ to 40 mΩ (milliohms).
  2. Standard Consumer-Grade 18650 Cells: Generally have an IR between 40 mΩ to 60 mΩ.
  3. Aging or Degraded 18650 Cells: IR can exceed 60 mΩ to 100 mΩ or more as the battery wears out.


Future Plans

EDU The Future Creative Writing Task.jpg

Looking ahead, there are exciting plans to further improve the device. My future plans for this project include:

1. Implementing a Cooling System using a small fan and thermistor to manage heat during high current discharge tests. The fan will automatically activate to cool the heatsink when the temperature exceeds a set limit, ensuring optimal performance and preventing overheating.

2. Integrating ESP32 WiFi capabilities for real-time remote monitoring of battery performance. Data will be logged and visualized on web dashboards or mobile apps, enabling live plotting of key parameters such as voltage, current, and internal resistance. This will make it easier to track battery performance over time, perform detailed analysis, and detect early signs of degradation.

Conclusion

DSC00238.png

This DIY multipurpose device offers an all-in-one solution for battery enthusiasts looking to test and evaluate Li-ion batteries. By integrating multiple functions into one device, you can charge, discharge, analyze, and measure the internal resistance of batteries. This DIY approach provides significant benefits over commercial products, allowing for customization, scalability, and deeper insight into battery performance without the higher cost associated with off-the-shelf devices.

One of the biggest advantages of a DIY project like this is the flexibility and expandability that comes from designing it yourself. Commercial products are often limited in their features and difficult to modify. With this DIY device, you can tweak the design, add new functionalities, and adapt it to different battery types or testing needs. Moreover, by working with open-source hardware and software, you have the freedom to improve, share, and build upon your work, fostering a collaborative environment within the maker community.

The open-source nature of this project encourages community involvement and continuous improvement. By sharing the hardware design and code, others can contribute new ideas and enhancements, making this device even more powerful and versatile.

If you found this project interesting or useful, please consider liking and sharing it with others who may benefit from this device. Your feedback and suggestions are invaluable to the continued development and improvement of this project. Feel free to suggest any features you'd like to see added or any improvements we can make.

Thank You!