Battery Charger using Arduino (DIY)

Arduino Controlled Battery Charger with Temperature and Over-Charging Protection

NiMH rechargeable batteries can be controlled and monitored by fixing an Arduino and charging circuit together. Details of the method are explained in this article.

If you are new, you can read about basics of batteries,  rechargeable and non-rechargeable batteries. 


Rechargeable Batteries

Rechargeable batteries can be used to charge your portable electronics. They not only save your money, but they also contribute to sustain environment when recycled in the best way possible. The most important to keep in mind is that they need to be charged properly for optimal functioning. This implies that a fully functioning and efficient charges is required in this case. Generally, people spend a considerable amount of money on a charger, but it’s much exciting to construct your very own charger. This project gives you all the details needed.

Circuit of Arduino based battery charger
Figure: Circuit of Arduino based battery charger

It is indispensable to bring this to your knowledge that there is no universal charging method for all rechargeable batteries. It depends on the chemical process being used in the method. Hence, every battery is charged differently than the other one. Since, we’re not able to include all the methods in this particular article, we are going to teach you a very common method of AA rechargeable battery i.e. Nickel Metal Hydride (NiMH).


How to Charge NiMH AA Batteries:

A NiMH battery can be charged in several ways. Which method to choose is totally dependent on how fast you want the battery to be charged. The charge rate in turn depends on the capacity of the battery. For instance: if the battery you’re choosing has a capacity of 2500MAh and then you charge it with a current of 2500 mA, then the charging rate is 1C. Likewise, if you charge it with a current of 250 mA, then the charging rate is C/10.

Charging Precautions

You need to overlook the voltage and temperature of battery so that overcharging cannot take place, while charging at a rate higher than C/10. Any slight mistake can be hazardous for the battery. On the contrary, when you charge your battery at a much slower rate, it is less prone to damage. Thus, the slower you charge your battery the better in terms of safety and maximizing your battery’s life. In this case, we’ll be using a battery of charge rate C/10.

The Charging Circuit:

A basic Arduino controlled power supply is the circuit design for this project. A 5 volt voltage source like an AC adapter or an ATX computer supply is used to power up the circuit. Because of certain restrictions, a USB port wouldn’t be suitable. The battery is charged through a 10 Ohm power resistor, a 5V source and a power MOSFET. The MOSFET is responsible to control the amount of current that will flow in the voltage source. In order to monitor the current, a resistor is attached by attaching each terminal to the analog input pins on the Arduino and by estimating the voltage on each terminal. A PMW output pin is used to control MOFSET on the Arduino.  Through a 1M resistor and 1 µF capacitor, the pulses of the pulse width modulation signal are evened out into a not so fluctuating voltage signal. This entire circuit and the way the components are placed in it helps the Arduino to monitor and control the current that is flowing into the battery.

Complete Schematic of Arduino Based Battery Charger
Figure: Complete Schematic of Arduino Based Battery Charger

The Temperature Sensor:

It is highly important to take necessary precautions while forming a circuit like this one. We recommend you to include a TMP36 temperature sensor to check the temperature of the battery every now and then. A temperature sensor outputs a signal voltage which directly helps to measure the temperature of the battery. Hence, no calibration will be required to set this sensor in place.


This sensor is installed by making a hole at the back of the battery and then gluing the sensor to it so that it rests against the side of the battery. The sensor pins are then attached to the 5V, GND and an analog input pin on the Arduino.

Temperature Sensor
Figure: Temperature Sensor

The Code:

The code to be used in this project is not very complicated. You need to plug in the values of battery capacity rating and the accurate resistance of the power resistor at the very top, in order to customize accordingly. The variables for the safety thresholds of the charger are also incorporated in the code. The maximum voltage you could allow through your battery is 1.6 volts. On the other hand, the maximum temperature is 35 degree Celsius. Moreover, the maximum charge time is 13 hours. Wondering what can be side effects? The charger will definitely turn off if you won’t follow this guideline.


The body of the code clearly implies that the system set in place will continuously measure the voltage of the terminal of the power resistor. This will help estimate not only the terminal voltage of the battery but also the current flowing into the battery.  The current flowing into the battery is then compared with the target current i.e. fixed at C/10. If the resulting current is different from the target current with a difference exceeding 10 mA, then the system is able to automatically adjust the output in the right way possible.


The serial monitor tool is incorporated to display all the data on the Arduino. To the USB port, you may choose to attach the Arduino to overlook the status of your charger. But this kind of practice is not very compulsory as a 5V power supply is attached to the Arduino.


You probably now are able to understand the entire process and methodology of how to construct your very own controlled battery charger. Just follow the guidelines carefully and then you’re good to go. Do not forget to apply those safety precautions as the contrary can cause severe damages which you won’t be able to handle.

You might also want to look at article of 7Ah battery charger using microbontroller.

For any help you can contact us or comment below for feedback. Like our Facebook page to stay tuned with us.

4 thoughts on “Battery Charger using Arduino (DIY)”

  1. You are a joker, where are the information? There is none and only written without any proof or details. If you do not know how to do it, do not act like know.

What do you think?

This site uses Akismet to reduce spam. Learn how your comment data is processed.