• Skip to main content
  • Skip to primary sidebar

Homemade Circuit Projects

Need circuit help? Post them in the comments! I've answered over 50,000!

Blog | Categories | About | Hire Me | Contact | Calculators-online
You are here: Home / Battery Charger Circuits / Arduino Battery Level Indicator Circuit

Arduino Battery Level Indicator Circuit

Last Updated on May 17, 2026 by Swagatam 96 Comments

In this post, I will show how to construct an Arduino based  battery level indicator, where a series of 6 LEDs show the level of the battery. If you are interested in monitoring and maintenance of your 12V battery, this circuit might become handy.

Table of Contents
  • Why Battery Level Monitoring is Crucial
  • How it Works
    • Calibrating LED Indicators
      • Author’s prototype:
    • Program Code:
    • How to Setup the circuit:
    • Adding an Auto Cut Off

Why Battery Level Monitoring is Crucial

All batteries have certain voltage limit to discharge, if it goes beyond the prescribed limit, the life span of the battery will reduce drastically.

Being electronics enthusiasts, we all might have a battery for testing our prototype circuits. Since we concentrate on the prototype during experiment, we care less on the battery.

The proposed battery charger circuit will show you how much energy left in the battery, this circuit may be connected to battery, while you prototyping your circuits. When this circuit indicates low battery, you may put the battery to charge. The circuit has 6 LEDs, one LED glow at a time to indicate the voltage level of the battery.

If your battery is full, the left most LED glows and you battery is dead or about to die, the right most LED glows.

How it Works

LED battery level indicator using Arduino code

The circuit consists of Arduino which is the brain of the system, a potential divider which helps the Arduino to sample the input voltage. A pre-set resistor is used to calibrate the above setup. The series of 6 LEDs will indicate the battery level.

Calibrating LED Indicators

The relation between LED and battery level is given below:

LED1 – 100% to 80%

LED2 – 80% to 60%

LED3 – 60% to 40%

LED4 – 40% to 20%

LED5 – 20% to 5%

LED6 - <5% (charge your battery)

The Arduino measures a narrow range of voltage from 12.70V to 11.90V. A fully charged battery should have voltage above 12.70V after disconnecting from charger. A low battery voltage must not go below 11.90V for a 12V sealed lead-acid battery.

Author’s prototype:

Arduino Battery level indicator prototype

Program Code:

//--------Program developed by R.Girish---------//
int analogInput = 0;
int f=2;
int e=3;
int d=4;
int c=5;
int b=6;
int a=7;
int s=13;
float vout = 0.0;
float vin = 0.0;
float R1 = 100000;
float R2 = 10000;
int value = 0;
void setup()
{
Serial.begin(9600);
pinMode(analogInput,INPUT);
pinMode(s,OUTPUT);
pinMode(a,OUTPUT);
pinMode(b,OUTPUT);
pinMode(c,OUTPUT);
pinMode(d,OUTPUT);
pinMode(e,OUTPUT);
pinMode(f,OUTPUT);
digitalWrite(s,LOW);
digitalWrite(a,HIGH);
delay(500);
digitalWrite(b,HIGH);
delay(500);
digitalWrite(c,HIGH);
delay(500);
digitalWrite(d,HIGH);
delay(500);
digitalWrite(e,HIGH);
delay(500);
digitalWrite(f,HIGH);
delay(500);
digitalWrite(a,LOW);
digitalWrite(b,LOW);
digitalWrite(c,LOW);
digitalWrite(d,LOW);
digitalWrite(e,LOW);
digitalWrite(f,LOW);
}
void loop()
{
value = analogRead(analogInput);
vout = (value * 5.0) / 1024;
vin = vout / (R2/(R1+R2));
Serial.println("Input Voltage = ");
Serial.println(vin);
if(vin>12.46) {digitalWrite(a,HIGH);}
else { digitalWrite(a,LOW);}
if(vin<=12.46 && vin>12.28) {digitalWrite(b,HIGH);}
else { digitalWrite(b,LOW);}
if(vin<=12.28 && vin>12.12) {digitalWrite(c,HIGH);}
else { digitalWrite(c,LOW);}
if(vin<=12.12 && vin>11.98) {digitalWrite(d,HIGH);}
else { digitalWrite(d,LOW);}
if(vin<=11.98 && vin>11.90){digitalWrite(e,HIGH);}
else {digitalWrite(e,LOW);}
if(vin<=11.90) {digitalWrite(f,HIGH);}
else {digitalWrite(f,LOW);}
delay(2000);
}
//--------Program developed by R.Girish---------//

How to Setup the circuit:

The calibration for this Arduino 6 LED battery level indicator circuit must be done carefully, if you did not calibrate correctly, the circuit will show incorrect voltage level of the battery.

When you turn on the circuit, it starts with LED test, where the LEDs glow up sequentially with some delay. This might help you to debug errors while arranging the LEDs.

1)    Set the voltage of your variable power supply to precisely to 12.50V.

2)    Open the serial monitor.

3)    Rotate the preset resistor clock wise or counter clock wise and bring the readings to 12.50V.

4)    Now, reduce the variable power supply to 12.00V, the readings on the serial monitor should show the same or very close to 12.00V

5)    Now, increase the voltage to 13.00V, the readings on serial monitor should also show the same or very close.

6)    At the same time when you increase or decrease the voltage, the each LED should turn on/off with different voltage levels.

Once the above steps are done successfully, your battery level indicator circuit will be ready to serve the intended purpose.

Adding an Auto Cut Off

The above explained Arduino battery level indicator circuit can be further enhanced by including an automatic battery full charge cut-off facility.

The following figure shows how this may be implemented in the existing design:

You'll also like:

  • full bridge battery charger circuitUsing MOSFET Body Diodes to Charge Battery in Inverters
  • highcurrentbatterycharegrcircuitLead Acid Battery Charger Circuits
  • chargingbatteryfromsmpssolarchargercircuit.Convert SMPS into a Solar Charger
  • Inductive charging 1Wireless Li-Ion Battery Charger Circuit

Filed Under: Battery Charger Circuits Tagged With: Arduino, Battery, Indicator, Level

About Swagatam

I am an electronics engineer and doing practical hands-on work from more than 15 years now. Building real circuits, testing them and also making PCB layouts by myself. I really love doing all these things like inventing something new, designing electronics and also helping other people like hobby guys who want to make their own cool circuits at home.

And that is the main reason why I started this website homemade-circuits.com, to share different types of circuit ideas..

If you are having any kind of doubt or question related to circuits then just write down your question in the comment box below, I am like always checking, so I guarantee I will reply you for sure!



Previous Post: « 1.5V Power Supply Circuit Diagram for Wall Clock
Next Post: Material Storage Level Controller Circuit »

Reader Interactions

Questions & Answers

Total Posts: 96
Newest Oldest
Fatin Nabihah Sairy
January 31, 2017 • 9 years ago #48529

Hi Mr swagatam well I need to do my final year project. I need to do battery indicator using Bluetooth and wifi. My question is do I need to do a vdr to avoid a more volt supply to my arduino+LCD+bluetooth module. I hope you can help me

Reply
SwagatamAdmin
February 1, 2017 • 9 years ago #48535

Hi Fatin, you can use a 7805 IC voltage regulator for ensuring a safe 5V for the Arduino.

Reply
Faizan Hamayun
March 27, 2017 • 9 years ago #49335

Hello;
I have been searching for a circuit that can detect if lithium ion 4.2v rechargeable battery is at fault i mean consuming very less current like 10-100mA but not getting the proper charging current.With LED indication.

Reply
SwagatamAdmin
March 28, 2017 • 9 years ago #49358

Hello, the only way to detect this could be through a current sensing resistor and a voltage amplifier circuit which will indicate whether the cell is consuming around 1C current or not……LM3915 IC looks a candidate for making this system.

Reply
Faizan Hamayun
March 28, 2017 • 9 years ago #49365

Can this be done using arduino with less parts i want to achieve the result.

Reply
Faizan Hamayun
March 28, 2017 • 9 years ago #49368

I only need one LED to indicate so small opamp like lm393 can be use?.Please suggest a circuit.

Reply
SwagatamAdmin
March 28, 2017 • 9 years ago #49380

you can try the following concept, keep only one opamp instead of the shown 4

https://www.homemade-circuits.com/2015/04/battery-current-indicator-circuit.html

Reply
SwagatamAdmin
March 28, 2017 • 9 years ago #49381

….connect the LED cathode to the input supply ground line.

LED will ON for good battery and OFF for bad battery…for an opposite response connect the LED across opamp output and positive line.

Reply
Akhil Singh
March 31, 2017 • 9 years ago #49464

can you provide a circuit for solar panel powered battery charging circuit that charges 12V 7Ah battery

Reply
SwagatamAdmin
March 31, 2017 • 9 years ago #49471

you can make the following circuit:

https://www.homemade-circuits.com/2012/04/how-to-make-solar-battery-charger.html

adjust the 10K to get exactly 14V for the battery, and use an input of 15V at 1 amp

Reply
isaac umoh
April 1, 2017 • 9 years ago #49512

Good evening….please sir how can i make the led to be constantly ON but Turn OFF when the battery is LOW

Reply
Faizan Hamayun
April 4, 2017 • 9 years ago #49587

If a dead battery attached to this circuit but the battery is also attached to the charging circuit how can we get low battery indication?.As charger output is above 13v so the green LED ON instead of red LED.What to do?

Reply
SwagatamAdmin
April 5, 2017 • 9 years ago #49593

when a good battery is connected the supply voltage will instantly go down and settle down to the battery discharge level…but for a dead battery this might not happen and will indicate something's wrong with the battery.

Reply
GR
May 8, 2017 • 9 years ago #50328

Hi, Faizan

Do not charge your battery along with this circuit, it won't indicate the correct battery level.

Regards.

Reply
Faizan Hamayun
April 25, 2017 • 9 years ago #50014

hello i have calibrated the circuit FOR LITHIUM ION battery charger i have connected the charger it shows 4.2v when no battery and when a 3.7v battery attached to it the serial monitor shows voltage more then 4.7v what to do?.Why it is not showing correct charging voltage or do i need to change the formula?

Reply
SwagatamAdmin
April 25, 2017 • 9 years ago #50024

Hello, Mr. GR will hopefully see your question here and respond appropriately….please be patient.

Reply
GR
May 8, 2017 • 9 years ago #50326

Hi, Faizan,

The circuit is NOT designed for Li-ion batteries, it is proposed for 12V SLA batteries.

The code is written for 12V batteries and will not monitor 3.7V Li-ion batteries.

Do not charge your batteries along with this circuit. It is designed to monitor the battery only on discharge.

Please read the article properly, this will keep most of the misunderstanding about the project at bay .

Regards

Reply
Faizan Hamayun
April 25, 2017 • 9 years ago #50023

Its adding battery voltage as well

Reply
Unknown
April 27, 2017 • 9 years ago #50088

hy sir i make circuit same as above but the serial monitor shows 20+ reading without battery.
and only secondary battery are use.

Reply
GR
May 8, 2017 • 9 years ago #50327

Hi Unknown….LOL 🙂

Please elaborate your issues and please comment you problem in a way that others can understand.

Regards

Reply
Faizan Hamayun
May 8, 2017 • 9 years ago #50320

Waiting for the reply anxiously.

Reply
SwagatamAdmin
May 8, 2017 • 9 years ago #50333

Please refer to your previous comment above, for the reply….

Reply
Faizan Hamayun
May 9, 2017 • 9 years ago #50346

OK if i calibrate for Li battery but once charging circuit connects what will be the changes to be done to detect original voltage of battery under charge? instead it add up the battery voltage with the charging circuit voltage.

Reply
GR
May 9, 2017 • 9 years ago #50352

Hi faizan,

You cannot calibrate the circuit for li-ion battery as the program is written for 12V battries only.

That's why you are getting unusual voltage readings on serial monitor when you connect the charger.

If you are looking for li-ion based projects this is not the right one.

Regards

Reply
Gizem Yılmaz
July 13, 2017 • 9 years ago #51671

Hi,
I need to do battery level circuit for my intern project. The will be 5v at the input and there will be five leds. For example if there is 1v just one of the leds will light then for 2v first two of themcan you help me about this?

Reply
SwagatamAdmin
July 13, 2017 • 9 years ago #51684

Hi, Mr, GR will be able to advise you better, I'll forward the question him soon….

Reply
GR
July 13, 2017 • 9 years ago #51687

Hi, Gizem

Are you sure about your design, because a 5V (4.5v etc) battery should not be allowed to fall to 1 Volt and most of the circuit will only work above 3V in general.

I will design a circuit for you, if you want me to proceed with your requirements.

Regards

Reply
Dinusha
August 11, 2017 • 9 years ago #52362

Dear sir,
Is it only use the battery terminal voltage as input? can i used this for stand alone PV system (12V battery monitoring)?.Because I want to disconnect the battery from the load or pv array at the required charging levels.

Reply
SwagatamAdmin
August 12, 2017 • 9 years ago #52367

Dear Dinusha,

Yes you can use it separately for monitoring battery only, the Arduino can be powered from the battery under monitor.

Reply
Dinusha
August 13, 2017 • 9 years ago #52404

Thank you sir.
Actually I want to design a controller circuit for stand alone pv system to energize the 12V DC bus. This controller must have the MPPT (with P & O algorithm). normally systems disconnected at the overcharging and over discharging the 12V battery.
I want to design a controller to disconnect MPPT at the battery charging is greater than the 95% ,then it track the voltage without MPPT until 100% charging. if the charging level less than the 95% then it connect to the MPPT again. can it do this by using arduino. ?
{i want to prevent the problem of cut off the MPPT at the No-load and fix this disconnection & re-connection in smoothly}

Reply
SwagatamAdmin
August 14, 2017 • 9 years ago #52410

Dinuasha, if your requirement is to keep the charging thresholds within the margin of 100% and 95%, then I think it could be done with a simple opamp circuit, using Arduino will be an overkill for such a a simple operation.

Reply
joel wanjala
November 10, 2017 • 9 years ago #55760

what if i want to indicate the battery level in percentage form on an lcd display instead of using LEDS, what can i do?? please advice

Reply
SwagatamAdmin
November 10, 2017 • 9 years ago #55768

Mr.GR will answer your question soon…

Reply
GR
November 10, 2017 • 9 years ago #55772

Hi joel,

Let me do some research on this, if it is possible to read between 0 to 100% voltage range. I will post a design soon.

Regards

Reply
PolloB
December 21, 2017 • 9 years ago #56891

sir,please give PIC Microcontroller based 12V battery capacity led level meter with charge controll.thanks

Reply
SwagatamAdmin
December 22, 2017 • 9 years ago #56901

Hi Pollo, presently I do not have this design, If I find one I’ll let you know…

Reply
Anupriya
March 9, 2018 • 8 years ago #58984

HI, In this the voltage level is indicated in the form of a LED. If it is possible to get the voltage level in the digital format

Reply
SwagatamAdmin
March 10, 2018 • 8 years ago #58997

Hi, it will require modifying the entire code and may not be possible at the moment…

Reply
Anupriya
March 10, 2018 • 8 years ago #59005

if it is possible can you please tell me

Reply
SwagatamAdmin
March 10, 2018 • 8 years ago #59008

I will have to contact the programmer for the customization, and therefore will be a paid service.

Reply
anu
March 14, 2018 • 8 years ago #59082

we are getting 54.59 as a input voltage which was displayed in the monitor

Reply
SwagatamAdmin
March 14, 2018 • 8 years ago #59083

sorry, could not understand your problem correctly, please explain it elaborately

Reply
ALLAN
October 8, 2018 • 8 years ago #64513

hello Sir, kindly suggest a circuit of your own design which useful to control 3 phase motor by not just merely using start-stop that can easily be worn out due to sparks and may I ask further if can I make it wireless thanks…

Reply
ALLAN Q. GUILLERMO
October 8, 2018 • 8 years ago #64514

Hello Sir, may I ask a favor again to help me design a circuit for me to control my three-phase motor using remote control thank you and God bless,..

Reply
SwagatamAdmin
October 8, 2018 • 8 years ago #64516

Hello Allan, I already have one related post in my website, which you can refer and try it out:

https://www.homemade-circuits.com/3-phase-induction-motor-speed/

remote control can be integrated once you successfully built the basic model as explained above.

Reply
sheraz ahmad
January 1, 2019 • 8 years ago #64784

Hi sir! dear sir how can we detect the presence of a 12v battery & the charger say 12v-10amp smps charging that 12v battery using arduino at the same time? my problem is if arduino adc channel measure the voltage using led display between battery terminals while connected to battery then the circuit is correct but if we disconnect battery from the charger how the arduino will detect the absence of charger terminal at battery terminal? i mean how arduino will detect presence or absence of charger at battery terminals?

Reply
SwagatamAdmin
January 2, 2019 • 8 years ago #64787

Hi Sheraz, When you connect an external voltage to a battery, the external voltage will sink and merge with the battery voltage to become a common voltage.

Suppose your battery is at 11V, and if you connect a 12V to it, then this 12V will instantly drop to 11V across the battery terminals, and then the battery will begin absorbing this voltage and charge until its terminal voltage reaches 12V. Once this happens, the charging will stop and both the sources will continue to be at this level as long as they are connected together.

Similarly, if you connect 14V, the final voltage will settle at 14V while the charger is connected.

So the only way to distinguish whether a charger is connected or not is through a current sensor stage, because the battery will begin drawing current from the charger while it’s being charged and this could be used for monitoring the presence or absence of the charger input.

Reply
sheraz ahmad
January 2, 2019 • 8 years ago #64797

sir i ‘m going to implement 10amp-12v smps design with an additional auto cutoff circuit using atmega8 and by placing 4 leds for 25%, 50%, 75% & finally 100% i will display this percent using atmega8 adc channel, like the circuit you presented in this article, i think if we power the atmega8 circuit by getting 5v from charger terminal by using some regulator then we will have to still use current sense circuit to know that whether battery is charging or not. without current sense circuit the display with also show that battery is 100% charge because the controller may sense the 12v-volt at the charger terminal if battery is disconnected. you are right sir by using current sense circuit this problem can be corrected.

Reply
SwagatamAdmin
January 3, 2019 • 8 years ago #64800

That’s right Sheraz, I think the following concept could be modified for achieving current based cut off.

https://www.homemade-circuits.com/2015/04/battery-current-indicator-circuit.html

Reply
Melchior
March 19, 2019 • 7 years ago #65946

Hy mr.Swagatam
i have home work to do project about controller baterry/automatic charging using Arduino Uno,MOSFET/Transistor and Voltage sensor…
i’m still confuged in arduino program code during charger and dischsarge….
may you help me…

Reply
View Older Comments

Need Help? Please Leave a Comment! We value your input—Kindly keep it relevant to the above topic! Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar



My Youtube Channel

Circuit Simulator

circuit simulator image



Subscribe to get New Circuits in your Email



Categories

  • Arduino Projects (95)
  • Audio and Amplifier Projects (134)
  • Automation Projects (18)
  • Automobile Electronics (103)
  • Battery Charger Circuits (88)
  • Datasheets and Components (109)
  • Electronics Theory (149)
  • Energy from Magnets and Earth (40)
  • Games and Sports Projects (11)
  • Grid and 3-Phase (20)
  • Health related Projects (27)
  • Home Electrical Circuits (13)
  • Indicator Circuits (16)
  • Inverter Circuits (100)
  • Lamps and Lights (162)
  • Meters and Testers (72)
  • Mini Projects (28)
  • Motor Controller (68)
  • Oscillator Circuits (28)
  • Pets and Pests (15)
  • Power Supply Circuits (91)
  • Remote Control Circuits (50)
  • Security and Alarm (65)
  • Sensors and Detectors (107)
  • SMPS and Converters (45)
  • Solar Controller Circuits (61)
  • Temperature Controllers (43)
  • Timer and Delay Relay (50)
  • Voltage Control and Protection (44)
  • Water Controller (37)
  • Wireless Circuits (31)



Other Links

  • Privacy Policy
  • Cookie Policy
  • Disclaimer
  • Copyright
  • Videos
  • Sitemap

People also Search

555 Circuits | 741 Circuits | LM324 Circuits | LM338 Circuits | 4017 Circuits | Ultrasonic Projects | SMPS Projects | Christmas Projects | MOSFETs | Radio Circuits | Laser Circuits | PIR Projects |



Recent Comments

  • Swagatam on DPDT Relay Working, Pinouts, Testing Explained
  • Swagatam on How to Modify SMPS for Adjustable Current and Voltage Output
  • Swagatam on Pure Sine Wave Inverter Circuit Using IC 4047
  • Nare Mashiachidi on DPDT Relay Working, Pinouts, Testing Explained
  • Nare Mashiachidi on DPDT Relay Working, Pinouts, Testing Explained

Social Profiles

  • Twitter
  • YouTube
  • Instagram
  • Pinterest
  • My Facebook-Page
  • Stack Exchange
  • Linkedin

© 2026 · Swagatam Innovations