measuring voltage of multiple batteries

Hello,

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.

Thanks,
Chris

You need two equal value resistors.

there is an explanation of voltage dividers with a circuit on this page: Voltage divider - Wikipedia ,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

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()
{
   Serial.begin(9600);
}

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.

Ran

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,
Chris

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.

hi,

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

which pins to jumper?
wat wires to connect?

thanx