Note: new firmware 1.1.0. Discharge voltage selectable to be either 3.77 volt for storage or 3.00 volt for complete discharge.
I had a couple of Li-Ion cells laying around, mostly salvaged from old phones and laptops. I tend to use these in little gadget projects, using the little EUR 0.50 TP4056 boards as chargers. However and as usual, time often gets in the way. Setting aside Li-Ion cells fully charged is not a good idea as it degrades the cells much faster than needed. Ideally they are stored at 40% State of Charge (SOH), but you need an advanced and expensive charger to do that. I decided to take a different approach and see if I could slam something together from the stack of stuff laying around.
First, charge the cell i.e. using said TP4056 board and a USB power supply. Then this circuit is connected and it will discharge the cell to 3.77 volt, but not further. The cell is now under low stress and can be stored for quite a long time.
It's build around my favorite tiny microcontroller, the Atmel ATtiny85. It's an offspring of the processors used in the Arduino family, is used in the Digispark boards and programmable through the Arduino IDE.
Here is what it does the moment you hook it to a cell.
- it beeps and blinks a LED in a short-long-short (102) pattern to show it's version and that it is alive;
- it check it's main voltage and assuming it is at or above 3.77 volt, it starts a constant current (300 mA) discharge;
- while discharging it flashes the LED indicating the battery voltage at this moment (see below);
- as soon as the voltage drops below 3.77 volt, the discharging circuit is disabled and the processor goes into an extremely low power state, only to wake up every 8 seconds to sound a piezo buzzer.
There is no automatic restarting. The power leads need to be removed an re-attached to restart the the device.
The LED repeatedly flashes three sequences to represent a three digit number, with a single long flash indicating a 0 and numbers greater than 3 separated in groups of three. So when we represent a long flash with an underscore and a short one with a dot, two examples are:
... . _ .. ... . _ .. 4.02 volt ... ... ... .. _ ... ... ... .. _ 3.80 volt
Step 1: The Hardware
Let's start with the part list
- an ATtiny85
- an 8 pin DIL socket (optional)
- a small piece of perfboard
- resistors (1 x 150R, 1 x 120R, 4 x 10R)
- two 1N4148 diodes
- a BD139 transistor
- a small aluminium heatsink
- a piezo buzzer (active type)
- an LED
- crocodile leads
The hardware is extremely simple. It is just an ATtiny85 micro-controller with attached to it an LED, a piezo buzzer and a constant current discharger. Simply follow the schematic. The discharger was based on (and explained in) the Laser Gun project, it is just using other values and a beefier transistor to allow for the 300 mA discharge current and approximately 1 watt of heat dissipation. Just build the device on a small piece of perfboard.
Note I used 4 resistors in parallel so they don't warm up too much. And in all honesty, I didn't have lower values laying around. The transistor dissipates most of the energy and can get quite hot. A small heatsink is needed.
One words on the leads. While 300 mA is not much it can lead to several tens of millivolts voltage drop over the leads. The ATtiny85 will measure the voltage it receives and a voltage drop over the leads will make it shut off too early. I used 0.75 mm2 speaker cable.
Cost is at most a few Euro's, well worth the longer shelf life of your Li-Ion cells.
Step 2: The Software
The software is reasonably straightforward and well documented. There are two functions that are a bit out of the ordinary as they manipulate the internal registers of the micro-controller. It is probably best to simply assume they work.
system_sleep () puts the processor in a very low power state.
battery_check () does the actual measurement of the supply voltage of the chip, called Vcc.
NOTE: PER NOVEMBER 2016 CODEBENDER IS CLOSING. I HAVE INCLUDED THE SOURCE CODE AS A FILE SO IT CAN BE USED IN THE ARDUINO IDE
And as always on ATtiny85 based projects: You need some sort of device to put your programs (or sketches as
they are called in Arduino parlance) into the chip's flash memory. Such devices are called ISP's. This instructable is not about how to build yourself an ISP nor how to use the Arduino IDE. If you're new to programming ATtiny85 chips, please read my "Butt Light" instructable, as it contains links to building your own ISP and how to use the Arduino IDE to compile and upload your firmware.