Introduction: Adding Regeneration in Brett's Arduino ASCD 18650 Smart Charger / Discharger

The DIY TESLA powerwall community is rapidly growing. The most important step in building a powerwall is the grouping of the battery cells in packs with an equal total capacity. This allows for setting the battery packs in series and easily balancing them for minimum discharge and maximum charge voltage. To achieve this grouping of battery cells, one needs to measure the capacity of every single battery cell. Measuring the capacity of tens of batteries accurately can be a big and overwhelming job. This is why the enthusiasts are usually using commercial battery capacity testers like the ZB2L3, IMAX, Liito KALA and others. However, among the DIY TESLA powerwall community there is a very popular DIY battery capacity tester - the Brett's Arduino ASCD 18650 Smart Charger / Discharger ( In this instructable, we will modify this DIY battery capacity tester so that the battery under test will transfer its energy to another high capacity battery, thus avoiding the waste of energy as heat through a power resistor (the common method for measuring battery capacity).

Step 1: Building a Prototype of Brett's DIY Battery Capacity Tester.

I would recommend to visit Brett's webpage and follow the instructions Then the idea for modifying this is shown in the schematic. Basically, instead of using a resistor to damp the measured battery energy, we use a very low Ohm resistor as a shunt. In our case, we use a 0.1 ohm 3-watt resistor. Then we build a DC boost converter with feedback. There are many links on how to build an Arduino controlled boost converter but I used the video by Electronoobs ( which is very educational. Also, Electronoobs here is using an Arduino so we will utilize part of his feedback loop code. Unlike the traditional boost converter, we will monitor and try to keep constant the discharging current, not the output voltage. Then the high capacity of the regen battery in parallel with a capacitor will smooth out the output voltage as shown in the picture (oscilloscope picture). Without the 470uF capacitor, you need to be careful of the voltage spikes.

Step 2: The Machine

Because all the project is currently under development, I decided to use commercial PCB boards and mount all the components. This is a learning project for me, thus PCB helped me to improve my soldering skills and learn all sorts of things about analog and digital electronics. I also got obsessed with increasing the regeneration efficiency. What I found out is that this setup results in >80% regeneration efficiency for discharge rates 1 amp. In the schematic, I show all the components needed in addition to what Brett is showing in his schematics.

Step 3: The Arduino Code.

FOr the Arduino, I used Brett's code and I included pulse width modulation (PWM). I used timers to run the PWM at 31kHz which (in theory but I didn't check) gives better efficiency in conversion. Other features include the correct measurement of the discharge current. You need to filter the measurement properly since our shunt resistor is 0.1 Ohm. In the discharge part of the code, the PWM duty cycle adjusts to keep the current constant.