Go Down

Topic: measuring voltage of multiple batteries (Read 3172 times) previous topic - next topic



I am trying to measure the voltage of two separate 7.4v lithium polymer batteries from a single Arduino board. Neither of these batteries will be powering the Arduino board directly. I understand a voltage-divider will probably be necessary in this application.

Can someone please explain what components will be necessary to accomplish this task; please be as detailed as possible.



Jul 19, 2009, 10:05 am Last Edit: Jul 19, 2009, 10:11 am by mem Reason: 1
You need two equal value resistors.

there is an explanation of voltage dividers with a circuit on this page: http://en.wikipedia.org/wiki/Voltage_divider ,for your application your would use equal value resistors for Z1 and Z2 - anything from 4.7k ohm to 10k would be ok.

You connect the battery to Vin,  Vout connects to the Arduino analog input pin.

The following sketch will print the voltage
Code: [Select]
const float referenceVolts = 5.0;        // the default reference on a 5 volt board
const int batteryPin = 0;          // +V from battery is connected to analog pin 0

void setup()

void loop()
  int val = analogRead(batteryPin);  // read the value from the sensor
  float volts = (val / 511.0) * referenceVolts ; // divide val by (1023/2)because the resistors divide the voltage in half
  Serial.println(volts);  // print the value in volts  


Will those batteries share a ground with the Arduino?

Measuring gets a little more complicated if they don't.



Jul 19, 2009, 11:10 am Last Edit: Jul 19, 2009, 11:11 am by mem Reason: 1
The grounds should be connected together unless the batteries are connected in series with each other.

Ran does have a good point, perhaps you can clarify if the batteries  will be connected to something else while being measured, and if so, how will they be connected.


Thanks for the replys,

I do not plan to connect the batteries together in series.

One battery will power my motors by connecting to a Robot Power Scorpion XL motor controller.

The other battery will power a pico-itx computer through a power supply. The Arduino board will be powerd via usb though the pixo-itx. I suppose it's possible this battery could also power the Arduino.

I understand that it is quite simple to read the battery connected to the Arduino using a voltage-divider on the Vin pin, but how to measure the other battery?

mem, can you please explain the reason why you suggest a resister in the range 4.7k to 10k for the voltage divider? I was planning to use two 1K resisters based on this tutorial: http://sites.google.com/site/adifferentlemming/Home/projects/arduino#TOC-Voltage-Dividers

Thanks again,


Jul 19, 2009, 04:28 pm Last Edit: Jul 19, 2009, 04:29 pm by mem Reason: 1
The higher the value the less power wasted through the resistors. 10k is the highest value recommended for analog inputs.  But the actual difference with 1k resistors is small so by all means use them if you want.

You can connect both batteries to two analog inputs through two sets of voltage dividers. Connect the two negative sides of the batteries and the Arduino grounds together.



can some one pliz tell me how to connect the scorpion xl motorcontroller to PIC 18f6722...

which pins to jumper?
wat wires to connect?


Go Up