Engineers Garage

  • Electronics Projects and Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe

How to measure voltage of multiple batteries connected in string/array in series or parallel combination with microcontrollers

By EG Projects February 7, 2021

Measuring an individual battery voltage or a whole bank of battery using any microcontroller(arduino, microship pic, Avr, Atmega, Intel, NXP, stm32)is an easy task. You can find many tutorials on internet on how to do so. But what about if we want to measure an individual battery connected to a cluster of batteries in series or parallel combination. Now its a hard task to accomplish. But still their are some cleaver ways to do so. In this post i am going to enlist some of the ways through which we can measure individual battery voltage which is a part of series or parallel connected string/array of batteries. 

Basic and popular battery monitoring technique – Voltage Divider Circuit

Basic and the most popular individual battery monitoring technique using microcontrollers in practice is voltage divider circuit. In voltage divider circuit two resistors are connected in series and source (battery) voltage is applied across its ends. Voltage is divided against the two resistors according to the resistor ohmic values.  

Voltage divider voltage divided against two resistors

Voltage divider voltage divided against two resistors

Why voltage divider?

Microcontrollers work on 5 or 3.3 volts(From here on we will take in to consideration 5 volt, techniques listed below can also be applied to 3.3 volt microcontrollers). So their pins are also working on 5 volt TTL logic. Voltage higher than 5 volts could potentially harm the pin or may fry the microcontroller. Solar panel, car, ups, generator and back up batteries normally are at 12 volts. Microcontroller can not measure 12 volts directly. So voltage divider is used here to divide the voltage in two half while ensuring that the one half voltage can not increase 5 volts in any scenario(charging etc). This half voltage is feed to microcontroller to measure the voltage.   

Voltage divider circuit with formula

Voltage divider circuit with formula

Now lets calculate the values for Rtop and Rbottom. Here we need some important considerations to be taken seriously. 

  • Low ohm resistors can sunk much current and wires could be heated instantly. Consequently wires can melt down in seconds. So always use sufficient amount of resistors for bigger ampere hour batteries. I selected one resistor Rbottom to be 10k ohm.
  • During charging battery voltage can increase to 18 volts. For example150 watt solar panel outputs 17 volts at 6 amperes during full sun, output voltage can even reach above 18 volts. Solar charge controller also output voltage approximately equal to 15 volts to charge the batteries.

Calculating resistance values

I am going to measure voltage across Rbottom and i decided its value randomly to be 10k ohm. We know Vout can be up to maximum 5 volts since nodemcu works and accepts maximum 5 volts at its I/O pins. Vin is 18 volts when the battery is charging(worst case scenario). Now we can find Rtop.

Voltage divider resistance value calculation

Voltage divider resistance value calculation
Now if 18 volts are at battery side it will be divided across resistors, 5 volts drops at 10k resistor and remaining 13 volts drops at 26k resistor. If battery is not charging and say supplying 12 volts what will be the voltage drop across resistors? Lets calculate it

Voltage drop against resistances of voltage divider circuit

Voltage drop against resistances of voltage divider circuit
Its obvious from the above discussion that the voltage across Rbottom will not exceed 5 volts now. I hope it makes sense to readers about the calculations. The question now is how the 3.33 volts is converted to 12 volt by nodemcu or how from 3.33 volts we can predict that at the battery side the voltage is 12 volts. Well a little more mathematics is involved here. Since the resistor values are fixed we can calculate the voltage ratio across the resistors with respect to the source and use it in code for actual voltage at source. How ratio is calculated is below.

Voltage divider ratio calculation

Voltage divider ratio calculation
Two cases are given above when source is at 18 volt and when source is at 12 volt in both the cases the ratio comes out to be constant value. This ratio is utilized in code for predicting the actual source/battery voltage. Ratio is multiplied with voltage at Rbottom for actual voltage value.
In order to take the tutorial on calculating resistance values for a 3.3 volt tolerance microcontroller visit the tutorial below. A demo project with free project code and circuit diagram is presented in the project. 

Battery monitoring with 3.3v tolerant microcontroller

Batteries connected in series

Batteries are connected in series to increase the voltage output. For example two 12 volt batteries are connected in series to build up 24 volts. Now how to measure voltage of individual batteries connected in series. See the circuit below. Four 12 volt batteries are connected in series to output 48 volts.  

Series batteries combination voltage monitor by microcontroller

Series batteries combination voltage monitor by microcontroller

In the above circuit four voltage divider circuits are used to measure voltage across each battery. The technique is to measure the voltage across high potential battery first, than against the lower ones and negating the subsequent batteries voltage from the one at higher potential. For example for the above circuit the measured voltage across  battery-1 is 48v and battery-2 is 36v. Negating 48v-36v=12v gives us battery-1 voltage. Similarly if battery-3 is at 23v. Than 36v-23v gives 13v. So battery-2 is supplying 13 volts in series string array. Other batteries voltages can be calculated with same method.
​In the above scenario for each battery their must be a dedicated analog channel. For higher string of batteries more analog channels are required and microcontrollers usually have 8 analog channels at max. So this method is feasible only when batteries in series combination are not greater than 4.

Note: For the above circuit the resistors values should be selected using the same formula given above.
A demo project using the above technique is made with arduino uno. Project contains free source code and circuit diagram. If you are interested take the tutorial. The link is below.  

Measuring string array of batteries voltages using arduino

Opto-isolators or Optocouplers

Using optocouplers is another way to do the same task. A linear optocoupler is one which can perform the job at best. It outputs an equivalent voltage to input but with drop in voltage rating. Optocouplers also isolates the microcontroller from the battery voltage and provides safety from high spikes. The problem with optocouplers is its hard to configure them and they require more effort than voltage divider. Circuit may also be messy. An extra power some time is also needed to power the optocoupler. Amplifier may also be needed at end to amplify the voltage output. Optocouplers also increases the circuit cost. At the end the major drawback is, it still requires a dedicated microcontroller analog channel to measure each individual battery.
​You can find many linear optocouplers with different ratings from Texas instruments and other vendors online. At the end the circuit will be hard to design and configure. A typical example is below. I hope no one has time to spend on it 😀    

Optoisolated battery monitor with microcontroller

Optoisolated battery monitor with microcontroller

Relays in battery monitoring

Double pole single through relayDouble pole single through relay

Relays can also be used to measure voltage across batteries. A
double pole single through relay is best choice here. A double pole single through relay has a single coil and double channels. When coil is energized two contacts are instantly made. Since two contacts are made. Battery both positive and negative terminals can be connected to this relay for input. A typical foot print of DPST relay is shown on the right hand side. Normally both the terminals are open and upon coil activation both the poles moves and completes the circuit line through which electric power can flow now. 

Double pole single through relays with batteries and microcontroller connections are shown below. Take a look I will discuss circuit its pros and cons below the diagram. 

Series battery monitoring with microcontrollers

Series battery monitoring with microcontrollers

 The circuit seems to be pretty simple in diagram but their are some serious pros and cons.
Pros 

  • Only one analog channel of microcontroller is required to measure multiple batteries.

Cons

  • Digital pins of microcontrollers are required to activate the relay coils and for individual battery an individual pin is required. Digital pins can be reduced by using multiplexers.
  • Each relay must be properly switched on and off one by one. If the two relays accidentally switched on at the same time their will be a huge blast due to short circuit of batteries.(It happen with me) .
  • Relay on off increases response time of voltage monitoring.  
  • Relay driving circuit is required.

I used arduino mega to monitor a cluster of 32 batteries with the same relay method. I used ULN2003 relay driver to drive the relay coils. UL2003 input is connected to multiplexer output. 4 to 16 multiplexer is used to drive 2 ULN2003 drivers. First i short circuited the 2 batteries and it cost me much at the end i finally fixed the code and inserted some delays which increased the hardware efficiency.     
I made a simple diy project with the same above logic. Arduino relay is used in the project. Click the below button to take the tutorial.

Arduino relay battery voltage monitor connected in series

Analog Multiplexers

Analog multiplexers can also be used instead of relays. Finding a suitable multiplexer and its configuration is as difficult as of optocoupler. I did not have much experience of analog multiplexers i can say any thing more abut them. 

Batteries connected in parallel

In parallel combination batteries are connected to increase the shelf life of the source or increase the time of power source to supply suitable voltage to load before needed to be recharged. In parallel combination voltage across each battery remains same. So we can not measure individual battery voltage in this case. 
These are some of the ways through which batteries connected in series or parallel can be monitored. If you have any more method in your mind please let me know about it.
If you are a DIY circuit maker or an electronics getting started enthusiastic or if you are a electronic major student the below mentioned project is for you. Its monitoring your car battery voltage, engine temperature and automatically switching head lights on off. Tutorial link is below.

Car automation – Battery Monitor, Engine Temperature, Head lights control

I also made an internet of things project on battery voltage monitoring over WiFi. User can see the battery status now on smart devices like mobile and desktop computers. Nodemcu esp8266 WiFi module is used in the project. Nodemcu Arduino ide is used to write, compile and download the code in nodemcu WiFi module. Project link is given below. 

Battery monitor over WiFi using nodemcu WiFi module

You may also like:


  • What battery chemistries are used in electric vehicles?

  • What are the different types of EV charging connectors?

  • What types of motors are used in electric vehicles?

  • What is Wireless Electric Vehicle Charging System (WEVCS)?

  • What is the role of embedded software in electric vehicles?

  • What drone parts you need to build a quadcopter?

Filed Under: Arduino Projects, ARM, AVR, Batteries, ESP8266, PIC Microcontroller, Products, STM32, Tech Articles
Tagged With: Arduino, arm, avr, esp8266, pic, stm32
 

Next Article

← Previous Article
Next Article →

Questions related to this article?
👉Ask and discuss on EDAboard.com and Electro-Tech-Online.com forums.



Tell Us What You Think!! Cancel reply

You must be logged in to post a comment.

EE TECH TOOLBOX

“ee
Tech Toolbox: Internet of Things
Explore practical strategies for minimizing attack surfaces, managing memory efficiently, and securing firmware. Download now to ensure your IoT implementations remain secure, efficient, and future-ready.

EE Learning Center

EE Learning Center
“engineers
EXPAND YOUR KNOWLEDGE AND STAY CONNECTED
Get the latest info on technologies, tools and strategies for EE professionals.

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


RSS EDABOARD.com Discussions

  • How can I get the frequency please help!
  • Elektronik devre
  • 12VAC to 12VDC 5A on 250ft 12AWG
  • SPI speed pic18f66j15
  • Antiparallel Schottky Diodes VDI-Load Pull

RSS Electro-Tech-Online.com Discussions

  • compatible eth ports for laptop
  • how to work on pcbs that are thick
  • How to repair this plug in connector where wires came loose
  • Actin group needed for effective PCB software tutorials
  • Kawai KDP 80 Electronic Piano Dead

Featured – Designing of Audio Amplifiers part 9 series

  • Basics of Audio Amplifier – 1/9
  • Designing 250 Milli Watt Audio Power Amplifier – 2/9
  • Designing 1 Watt Audio Power Amplifier – 3/9
  • Designing a Bass Boost Amplifier – 4/9
  • Designing a 6 Watt Car Audio Amplifier – 5/9
  • Design a low power amplifier for headphones- 6/9

Recent Articles

  • ITG Electronics releases gate drive transformers with 200 – 450 V DC capability
  • Stackpole introduces HCJ jumpers with 70.7 amp continuous current capability
  • Infineon releases MCU with 128K flash and multi-sense capabilities
  • ST introduces 600V GaN gate drivers with 300 ns start-up time
  • ABLIC releases S-19116 automotive voltage detector with 6.8μs response time

EE ENGINEERING TRAINING DAYS

engineering

Submit a Guest Post

submit a guest post
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • Battery Power Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • EV Engineering
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • Subscribe to our newsletter
  • About Us
  • Contact Us
  • Advertise

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy

Search Engineers Garage

  • Electronics Projects and Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe