Introduction: Battery Checker With Temperature and Battery Selection
Battery capacity tester.
With this device you can check the capcity of 18650 battery, acid and other (the biggest battery I tested It's 6v Acid battery 4,2A). The result of the test is in milliampere/hours.
I create this device because need It to check capacity fake china battery.
For safety, I added, using a thermistor, the temperature of the power resistance and battery to prevent going too hot, with this trick I can check 6v Acid Battery without fire the board (in the cycle of discharging some time go to hot power resistor and the device wait 20 seconds to reduce temperature).
I select little micro controller atmega328 compatible nano (eBay).
All the code is here.
Step 1: Change From Base Project
I stole the idea from the project of OpenGreenEnergy, and I redo the board to add features, so now become more general.
v0.1
- VCC of Arduino is now automatically calculated;
- Added variable to change setting in a more comfortable way.
- Added percentage of discharging
- Added temperature of battery and power resistor
v0.2
- Added possiblity of battery selection
- Created prototype board (look the schematic), with the screen, button and speaker outside of the board because in the future I'd like to create a package.
- Added management of the temperature limit to the power resistor so I can block process when temperature rising beyond 70° (over this temperature power resistor derating).
v0.3
- Coming soon a board from this service https://www.pcbgogo.com?code=y .
Step 2: V0.2 of the Board
In v0.2 to support various types of batteries, I created a structure that must be filled with battery name, min voltage and max voltage (I need help to fill it :P).
// Structure of battery type<br>struct BatteryType { char name[10]; float maxVolt; float minVolt; }; #define BATTERY_TYPE_NUMBER 4 BatteryType batteryTypes[BATTERY_TYPE_NUMBER] = { { "18650", 4.3, 2.9 }, { "17550", 4.3, 2.9 }, { "14500", 4.3, 2.75 }, { "6v Acid", 6.50, 5.91 } };
Now I use a set of 10k resistors for the voltage divider to read double temperature of analog input. If you want change voltage support, you must change this value (explain better next):
// Battery voltage resistance #define BAT_RES_VALUE_GND 10.0 #define BAT_RES_VALUE_VCC 10.0 // Power resistor voltage resistance #define RES_RES_VALUE_GND 10.0 #define RES_RES_VALUE_VCC 10.0
If you don't use thermistor, set this to false:
#define USING_BATTERY_TERMISTOR true #define USING_RESISTO_TERMISTOR true
If you use a different i2c display, you must rewrite this method:
void draw(void)
In the project, you can find fritzing schematics, photos,and more.
Step 3: Breadboard: I2c Character Display Controller Expanded
I used a generic character display, and I built the i2c controller and used it with my custom library.
But if you want, you can take a normal i2c controller (less than 1€) with a standard library, the code remains the same. All code of display is in draw function so you can change that without change other things.
Better explained here.
Step 4: Breadboard: Character Display With I2c Integrated
The same schema without i2c controlled expanded.
Step 5: Realization
For measuring voltage we use the principle of a Voltage divider (more information on Wikipedia).
In simple words, this code is the multiplier factor to measuring battery voltage.
batResValueGnd / (batResValueVolt + batResValueGnd)
I inserted the 2 resistances of batResValueVolt and batResValueGnd value after and before the analog read wire.
batVolt = (sample1 / (1023.0 - ((BAT_RES_VALUE_GND / (BAT_RES_VALUE_VCC + BAT_RES_VALUE_GND)) * 1023.0))) * vcc;
sample1 --> is the average analog readings;
vcc --> reference Arduino voltage;
1023.0 --> is the reference maximum value of analog read (Arduino analog read go from 0 to 1023).
To get amperage you need voltage after and before power resistor.
When you have the measure the voltage after and before the power resistor you can calculate milliampere that consumes the battery.
The MOSFET is used to start and stop battery drain from power resistor.
For safety I inserted 2 thermistors to monitor battery and power resistor temperature.
Step 6: Extensibility
I try to crete a prototype board that is extensible, but for now I use only a minimal set of pins (in future I'll add leds and other buttons).
If you want support voltage greater than 10v you must change the resistor value of battery and resistance in according to the formula
(BAT_RES_VALUE_GND / (BAT_RES_VALUE_VCC + BAT_RES_VALUE_GND)
in the schema Resistor power voltage
Resistor power voltage GND 1/2 / (Resistor power voltage 2/2 + Resistor power voltage GND 1/2)
Pink is down soldering
Step 7: List of Parts
Amount Part Type Properties
- 2 5mm Screw TermInal PCB Mount Screw Terminal Block 8A 250V LW SZUS (eBay)
- 1 Arduino Pro Mini clone (compatible Nano) (eBay)
- 1 Basic FET P-Channel IRF744N or IRLZ44N (eBay)
- 11 10kΩ Resistor resistor 10kΩ (eBay)
- 2 Temperature Sensor (Thermistor) 10kΩ; (eBay)
- * Generic male header form ♂ (male); (eBay)
- * Generic female header form ♀ (female); (eBay)
- 1 PerfBoard board Prototype board 24x18 (eBay)
10R, 10W
power resistor (eBay) I find mine in an old crt TV.
Step 8: Board: Reset, Gnd E Button to Select Battery
In the left part of the pins you can find the button and buzzer.
I use 3 buttons:
- one to change battery type;
- one to start discharging of selected battery;
- then I use reset pin to restart all, and activate new operation.
All pin is already pulled down so you must activate with VCC.
Reset is activate with GND.
Pink is down soldering
Step 9: Board: I2c and Power Supply Pins
To the base you can see the VCC, GND and SDA, SCL for display (and other in the future).
Pink is down soldering
Step 10: Board: Thermistor and Measuring Voltage
To the right there are pins to read thermistor value, one for power resitsor thermistor and the other for (male/female pins to attach) battery thermistor.
Then there are analog pins that measure differential voltage after and before power resistor.
Pink is down soldering
Step 11: Board: Resistor to Measuring Voltage
Here you can see the resistor that permit to support voltage double than arduino pin (10v), you must change this to support more voltage.
Pink is down soldering
Step 12: Soldering Step: All Pins
For first I add all pins and soldering It.
Step 13: Soldering Steps: Pulldown Resistor and Thermistor
Then I add all pulldown resitor (for buttons) and i2c connector (display).
Then the power resistor thermistor It's very important, with acid battery going too hot.
Step 14: Soldering Steps: MOSFET, Resistance to Check Voltage
Now we must insert mosfet to activate discharging and resistance to check voltage.
2 resistance for voltage before power resistor 2 resistance for voltage after power resistor, when you have this voltage you can calculate milliampere consuming.
Step 15: Code
The microcontroller is compatible nano, so you must set your IDE to upload an Arduino Nano.
To work you must download code from my github repository.
Than you must add 3 library:
- Wire: standard arduino library for i2c protocol;
- Termistor Library from here not the library that you can find in arduino IDE, but my version;
- LiquidCrystal_i2c: if you use extended/custom version of i2c adapter (my version) you must download the library from here, if you use the standard component you can take the library from arduino IDE, but all is better explained here.
I don't test LCD with standard library, It seems to me that they are interchangeable, but if there are some problem fell free to contact me.
Step 16: Result After Assembling.
The base board is in the photo, then we can going to test It.
Step 17: First Select Battery Type
As described we have a map of value with configuration of battery.
// Structure of battery type<br>struct BatteryType { char name[10]; float maxVolt; float minVolt; }; #define BATTERY_TYPE_NUMBER 4 BatteryType batteryTypes[BATTERY_TYPE_NUMBER] = { { "18650", 4.3, 2.9 }, { "17550", 4.3, 2.9 }, { "14500", 4.3, 2.75 }, { "6v Acid", 6.50, 5.91 } };
Step 18: Start Discharging
Click of second button start discharging.
In the display you can see current milliampere, milliampere/hours, percentage of discharging, battery voltage and temperature of power resistor and battery.
Step 19: Exceptions: Battery Removed
If you remove battery discharging process going to pause, when you reinsert It restart at the last value.
Step 20: Exceptions: Temperature Alert
If temperature (battery or power resistor) going to hot, the discharging process go to pause.
#define BATTERY_MAX_TEMP 50 #define RESISTANCE_MAX_TEMP 69 // 70° on datasheet (Derating resistors) #define TEMP_TO_REMOVE_ON_MAX_TEMP 20
The default value for max temperature is 50° for battery and 69 for power resistor.
As you can see on comment power resistor is affected by derating when going over 70°.
If alert is raised start TEMP_TO_REMOVE_ON_MAX_TEMP seconds of pause to put low temp.
Step 21: Test Amperage
The result of amperage test is good.
Step 22: Package
With separated component the package result simple to realize.
In a box must do a rectangle for LCD, the holes for push buttons, and an external female barrel to supply voltage from power supply.
Push button not need pull-down resistor because I add It already on board.
When I have some time I create and post it.