Go Down

Topic: Arduino-based opensource NiMH battery charger (Read 43524 times) previous topic - next topic



first post here. I'm developing on an Arduino-based NiMH (for AA or AAA) battery charger, I'm calling it Quite Smart Charger (or QSC). Eventually the project would allow to easily build a DIY smart battery charger that is fast but does not wear the battery through overcharging. Right now I have two sketches, one for discharging and one for charging. However the same circuit handle both charging and discharging so switching between the two is only a software issue (they can be integrated in a single sketch). So far only a single cell is supported. For charge termination I implemented 3 methods: negative delta V, timeout, overvoltage. The negative delta V method is a bit tricky since a 5-10mV voltage dip must be detected. This is the reason I use both HW and SW filtering. Optional temperature dT/dt sensing is on plan. The battery is "sensed", so, to start charging, you just push the battery in, to pause you pull the battery out. Led on 13 pin is ON while waiting for a battery.

I'm trying to keep the number of components to a minimum. However an external (at least 1A) powersuppply is compulsory for fast charging. The circuit I implemented uses an LM2941 (that includes a nice ON/OFF pin) to provide a constant current--see the attached schematic and picture. It uses 3 arduino PIN, 2 digital IO to control charge and discharge (pwrPin, dischargePin), and an analog input to monitor the battery voltage (inputPin). The circuit charges when pwrPin is LOW (and dischargePin LOW). Discharges with dischargePin HIGH (and pwrPin HIGH).

I do heavy filtering both hardware (1k-22uF LPF) and software averaging 8 voltage reads, once a second. 60 voltage acquisitions (1 minute) are stored in a circular buffer and averaged to have a stable reading once a minute to detect the negative delta V or overvoltage.The voltage acquisition is sent once a second to the serial port for logging. Additional info are on the header comment on the sketch file.

The discharge takes place at a constant current monitoring the cumulative energy (in mAh) being discharged.

So, please provide feedback, suggestions or additional ideas/contributions. Also would be nice to have some charge logs (serial dumps) for different cells in order to optimize the charging process.

Eventually we can get the best NiMH charger based on opensource hardware/software ;).

PS: For NiMH charging info you can refer to:
and linked documents.


Feb 15, 2012, 07:34 pm Last Edit: Feb 15, 2012, 07:37 pm by Tritemio Reason: 1
I just noticed that to run the discharge sketch you need a tiny library: Voltmeter. I attach it now. Please copy those files in the sketchbook/libraries/Voltmeter folder.


This is a great project.  I just started a similar project for 1 to 10 cells.  I have started my experiments with a simple voltage divider consisting of 2 resisters.  This is exciting.  Hopefully I can help contribute to the project!


Do you have pictures or schematics?

How is your project going?



What is the IC called out it seems you have labeled as an LM2961 but I have a hard time finding a datasheet or even a chip with that designation, can you help me out?




I was also thinking of making this project but it is not in the priority list right now.
I was just thinking to use the Arduino to measure the charging current and voltage in the battery and program it to stop charging after sensing a certain voltage or current level (indicate that NiMH is full), or may be do a trickle charge.

Good Luck, and keep us posted.


Hi everybody,

I didn't had time to develop further the QSC (Quite Smart Charger) project and unfortunately I'm quite busy right now, but I would gladly give guidance to anybody wants to take over the project.

Actually I was prompted to came back to the forum by a PM (since I have email notification), so if I don't answer please send me a PM and will be much more likely I'll notice it.

@jaydie: you can do the charger as you said (and the overvoltage feature on QSC does exactly that) but I noticed that, during charging at high current (>300mA), the NiMH voltage can reach values as high as 1.8V in some cells, or 1.6V on others. So with a fixed value you will either overcharge some cell or undercharge others. That's why I implemented the negative delta V method, that is not perfect either. So there is a timeout and an overvoltage protection also.

@wwbrown: the IC is the LM2941 low-dropout 1A voltage regulator. The nice thing about this IC is that it has  ON/OFF pin. The LM2941 in TO220 should not be hard to find. You can also build the circuit with a more ubiquitous LM317, that is not low-dropout (you need minimum 2 V between IN and OUT) and does not have an ON/OFF pin, so you need an additional power MOS to shut it down.

@pavels (PM):
1. The charging current is constant and determined by R* value. The only practical way to make the current software programmable in a range of values is using a DC/DC. Or using 2 or 3 different resistors values and select the level that you want with some power-MOS with low Rds-ON.

2. For R* selection you can use 2 0.5W resistors of 3.3 or 4.7ohm in parallel to obtain a current of 760mA or 530mA respectively. I didn't had big problems finding the resistors.

3. As you noticed, the discharge current is not at constant current as it across a resistance. The voltage though is quite constant when the cell is charge. When the voltage begins to go down there is a small energy left. The voltage-time curve is knee-shaped with an almost constant part (of several hours) and a sharp decrease of voltage (in few minutes) once the stored charge is finishing.

4. To charge multiple batteries indipendently you need to duplicate the circuit and the arduino controller.

5. In principle the mot efficient way of charging would be with a DC/DC or even better with a dedicated IC that takes care of the charging like the MAX712, MAX713. But since all the charging logic is implemented by the IC there is no need for the arduino anymore (except if you want to do some fancy display or USB communications).

Hope this information can be helpful.



Hi Antonino, thanks for sharing this interesting project.

Since renewable energy can only grow in importance, and I believe it will become very important, I am looking at your project as a good starting point for an "Open Source Battery Charger" project, which I think can be part of a kind of "Open Source Renewable Energy Toolbox" project/iniatiave…

My current thinking is to use QuiteSmartCharger as the charger MODULE together with a SOLAR MODULE and a BATTERY MODULE (could be 1 single 1.2V Cell), working as some kind of Renewable_Solar_Power_Unit (and also later, as Renewable_Wind_Power_Unit, etc)…

Solar Module + QSC + Battery Module = Renewable_Solar_Power_Unit

What I am thinking is the creation of a "Desktop Renewable Solar Unit", simple enough and cheap enough for the common citizens to use, manipulate, adapt, etc… where "desktop" means personal scope, small size, stuff that can be manipulated by the individual (like a desktop computer) using a single desk as the "workshop", and also, because the design is intended to be something to work with personal computers and Arduinos, Raspberrys and microcontrollers...

So, the word "desktop" just means "around the scope of a personal desk", like the PC (personal computer), that took computers from big scientific and industrial arenas and made its benefits available to common citizens...

This is a good way to look at this possibility:
i) Mainframe Computer <==> Big Power Utility Companies
ii) Mini Computer <==> Hundred of thousands Dollars solar farms and wind turbines
iii) Desktop PC <==> (kind of) "DESKTOP" RENEWABLE ENERGY TOOLS

QSC, at least in my point of view, looks a very interesting project to consider for this "category"...

I still learning about the subject of recharging batteries (Ni-Cad, Ni-MH, etc), so I am going to get a LM2941 and build QSC and do some experiments first… after that, I am thinking about experimenting also with LM317 with a MOSFET switch, since the LM317 is a popular IC, easy to get and very cheap…

For this first round of learning, I am reading a lot of information before going to the practical side of it, and I have some question that I like to ask, perhaps the answers can also help others…

If you can, or anybody that has experimented the (QSC) circuit/software, or anybody with enough knowledge, please give us a little input on the following questions:

1. What is the minimum (stabilized) IN-Voltage needed for the charger-circuit to work, considering just one 1.2V Ni-MH cell as target?

2. On the photo, are you using 2R7 Resistor for R* and also for Rd?

3. As for Resistor Rd (discharge resistor), 2 resistors of 0.5 Watt in parallel will fit the job?

4. For the discharge circuit (target 1.2V single cell), does it work with 1Amp, N-Channel, Low Rds-ON, (Power) MOSFET, or do I need to use something with higher Power capability like 5Amps, 20Amps?

5. Does the discharge MOSFET(s) need heat-sink?

[3 extra questions]
a) Is it correct to "break" your scheme into the "charger block", "discharge block" and "voltage reader block" according to these picture I am posting below?

b) Is the LM317 circuit below enough to work as an equivalent constant-current charger, so that we can adapt/use it with QSC software (preferable keeping both options with minor change in the soft)?

c) I am seeing some information about a new (?) Ni-H2, nickel hydrogen, type of batteries, does this new (?) type have, more or less, the same features as the Ni-Cad and Ni-MH, so that we will be able to use QSC hard/soft with them, as well?

Thanks all,

PS [Dedicated IC(s) versus MCU Controlled]
As you pointed, a dedicated IC can take care of every important aspect, so that the job can be accomplished without us having to worry about all these aspects, but I want to go on the direction of microcontroller basic designs because they offer much more in terms of flexibility, easy to modify, simplicity to understand, higher capacity to provide information (in digital form) and the ability to respond to control in a wide variety of forms, which means that they are much more "intelligent" in relation to the environmet... so, even with initial cost higher and using more complex set of hard/soft than the dedicated ICs, the MCU based design can EVOLVE (in the OpenSourcistic fashion) and adapt to a wide range of needs, thus justifying the initial cost and a little complexity...


About the main IC component:

Since the LM2941 is not as common as the LM317 is, I am looking for equivalent ICs (to the LM2941) and found the Sharp PQ20RX11 and the New Japan Radio NJM2389F (this last one does not have the on/off pin) to also include in the tests/experimentations…

[pict Sharp PQ20RX11]

[pict New Japan Radio NJM2389F]

So far, the LM317 with a power MOSFET "on/off" switch is the "most common/popular component" option, undoubtedly the easiest to get and the one that enjoy the bigger amount of online information, plus also important, the cost of the components are very low…

a) Easy to find "on the shelf" (all electronics shops keep in stock)
b) Cheap
c) Large amount of online information (accumulated know-how is huge)

The reason I am thinking/going to test all these options is because I want to make them work together with solar panels, which I also want to make as "desktop" (small and flexible) as possible…

[pict Solar Cell]

[BATTERINO UNI(Cell) - Arduino to its "core"]
I think one Arduino can handle more than one Charger-Circuit at the same time, but when we think about the creation of a possible "Unit of Renewable Solar Charger" and consider the VAST variety of batteries sizes, types and shapes (physical), perhaps one MCU per Charger-Circuit will be the most powerful solution, so we can think about stripping down the Arduino Platform to its core engine, plus some few basic components… so we can make it economically viable, from the point of view of this idea specifically…

[pict Batterino Uni]

Again, I like to express my opinion that, EMBEDDING Arduino hard/soft (or any other MCU platform) into things may sound unnecessary luxury, but I believe that the "POWER" we can get back will justify the thinking, as it will allow us to think "higher" than pure (clever) electronics and its benefits…

Well, lots of steps need to be accomplished (first the charger, then the solar, etc), it may take some time but I think it can be done and believe it make a lot of sense…



For people with interest in the subject, this following table (2 figures), from Panasonic, help us to understand better the methods for recharging (Ni-MH)…

[Related Graphic]

*More information in PDFs can be found here:


The following diagram tries to explain my point of view about how a Solar Module is connected with a Charger Module...

If we can have OpenSource Hard/Soft, both Modules working together, I think, we will have an interesting combination...

Solar, when combined with STORAGE (batteries), creates new possibilities...



And, to power the Arduino itself (5Volts), we can use a STEP-UP device and 2 batteries cells to get the necessary 5 Volts to power Arduino via de USB connector.

A 3 pin TO92 device like the HT7750 can work from input of 1.2V cell and produce the 5 Volts…

It will work with only one 1.2V cell, but I am not sure if it can create enough current (milliamps) to run Arduino properly… 2 cells should be enough to run basic stuff with Arduino…

[Batterino is ok with 1 cell ?!?!]
The Batterino scheme (above), because it is more simple, will probably run well from only 1 Battery Cell and the HT7750 VOLTAGE STEP UP device… well, in any case it will depend on the total current that the duino and the application requires…



The more I learn and think about the subject of recharge, batteries and renewable, the more I am thinking about the Open "Desktop" Scope Renewable Tools possibility…

Yesterday I've found a website with about 50 infographic pictures with information about renewable energy. Germany seems to be THE leader in renewable and this website is mostly data about Germany… VERY INTERESTING…

I selected 5 pictures to show here (you can download PDFs, PNGs and JPGs high quality from the site) because I believe they are related to my argument around a possible "Desktop Scope" for renewable tools…

[Info-graphic 1 - Solar and Batteries, Together]

This graphic shows (more or less) the relationship that solar energy and batteries/storage have to each other…

[Info-graphic 2 - Small is Beautiful]

This graphic uses 3 interesting words (terms): BIDIRECTIONAL, INTELLIGENT & SMALL PRODUCERS…

a) The term "intelligent" is pointing towards the implication of things like Arduinos, Raspberrys and Microcontrollers…
b) The term "small producers" is, in my point of view, an indication towards the "desktop size (scope)" that I am referring above...
c) And, "bidirectional" may be an indication that, like in the internet, PEOPLE CAN READ AND WRITE, thus consuming and producing instead of only consumption…

[Info-graphic 3 - Desktop PC = Computing Democracy]

This graphic shows how much INDIVIDUALS are actually the owners and source of the Germany Renewable Energy effort…
For me, it is another indication that renewable (energy) can go as far as a PERSONAL scope…

[Info-graphic 4 - Efficiency Means Soft/Hard Systems]

Renewable Energy, will work very well when there is an EFFICIENCY way to use the energy, which, in my point of view can be accomplished with the use of MCUs, Arduinos, RasPIs, etc…

[Info-graphic 5 - Germany Is Making 27% of Electricity from Renewables]

As of 2014, 27% of electricity generated in Germany comes from Renewables, which means that it is possible today…

[Info-graphic 6 - Solar is a "Hot Topic" (2014)]

This graphic shows, in strong-yellow color, how much solar energy creation capacity was added in 2014 alone… look at China, Japan and US slices for 2014…

If you have any interest in solar and renewables, I highly recommend the site (where you can find all the pictures and much more in PDFs)...

For me, the general idea is that PERSONAL/INDIVIDUALS will play an important role in the current and future development of the Renewable Energy Global transition, and Solar and Batteries can and should be also, considered at this (personal) level/scope…

I found the LM2941 on a local shop, and will be ordering the Sharp and the NJR regulators as well as some solar panels and some Ni-Cd and Ni-MH specific for development/testing purposes… I think I have gather enough of basic theory of the subject, sufficient to start the practice… also, after the Arduino version, I will like to adapt as much as possible to some PIC MCUs and to Linux Boards like the RaspberryPI (now with the $5 RasPI Zero it is even more interesting)… this is part of my effort towards an "ECO COMPUTING" thinking…


Go Up