Measuring 12V battery voltage

Breakout boards, sensors, other Adafruit kits, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
irwinr
 
Posts: 3
Joined: Tue Dec 17, 2013 2:01 pm

Measuring 12V battery voltage

Post by irwinr »

Hello,

I want to monitor the battery voltage in my RV. I have a Raspberry Pi and I know I can add an ADC to measure up to 3.3V, but I need to measure up to around 15 volts to account for peak voltages on the DC system from the charger.

This means I'd either need to figure out which two resistors I need to build a voltage divider and wire that up with an ADC, or find something that can measure higher voltages out of the box.

I came across this: https://www.adafruit.com/products/904 Which says: "you can just use the handy INA219B chip on this breakout to both measure both the high side voltage and DC current draw"

The thing is, I don't care about current draw. In fact my goal here is for this sensor to minimize current draw because I don't want my battery sensor to run my batteries down. So I have two questions:

1.) It appears that the "voltage" is measured between Vin- and GND. If this is true, and I don't care about measuring current, couldn't I just connect the positive side of my battery to Vin+, leave Vin- disconnected (IE: Don't attach any "load") and connect GND to the negative side of the battery and measure the voltage that way?

2.) Is it possible to use this with Raspberry Pi? It looks like it's designed for Arduino, but I'd rather not complicate my project by adding an Arduino into the mix.

If I'm crazy and the INA219 is not the right approach, how do I determine the best resistors to use for a voltage divider to convert 15 volts down to 3 volts? The problem I face is I obviously want higher resistance resistors to minimize vampire drain on my battery, but if I make the resistance too high there may not be enough current for the ADC to read.

-Jeremy

User avatar
adafruit_support_bill
 
Posts: 88096
Joined: Sat Feb 07, 2009 10:11 am

Re: Measuring 12V battery voltage

Post by adafruit_support_bill »

A voltage divider is the simplest way. The basic formula is:
Vout = Vin * R2/(R1 + R2)

And the circuit looks like:
Image

To get 3v from a 15v signal, you need to divide by 5. Using standard resistor values, you could build this using 12K ohms for R1 and 3K ohms for R2.

3v = 15v * 3k/(3K + 12K)

irwinr
 
Posts: 3
Joined: Tue Dec 17, 2013 2:01 pm

Re: Measuring 12V battery voltage

Post by irwinr »

If I'm trying to monitor battery voltage fairly precisely, don't I need to worry about resistor tolerance?

Standard resistors generally have 5% tolerance. If my math is correct, that means that if I use 5% tolerance resistors and I read 3.0 volts, that could mean the Vin was anywhere from 13.857 volts to 16.263 volts. That's a swing of 2.4 volts. I need to be a lot more precise than that. I'd like to be within +/- 0.1 volts.

Also, looking online, I don't see too many 3k resistor options, it seems they are generally 3.3k, which means at 15 volts I'd be at 3.2 volts instead of 3.0, but I suppose that's still under the 3.3 volt ceiling of the Pi. I was just hoping to stay well under the 3.3 volt limit so I don't fry anything.

This is why I was really hoping I could just use the INA219. It's the same price as the 12 bit ADC for the Raspberry Pi and I don't have to worry about building a voltage divider. I'm guessing by your reply that the INA219 won't work (easily) with the Pi?

-Jeremy

User avatar
adafruit_support_bill
 
Posts: 88096
Joined: Sat Feb 07, 2009 10:11 am

Re: Measuring 12V battery voltage

Post by adafruit_support_bill »

You should be able to find those values in 1% resistors. In any case, as with any sensor (including the INA219), you would need to calibrate it against a standard voltage if you want that level of accuracy.

Or buy a bunch of 2Kohm resistors (they are dirt-cheap in bulk). If you can't find them in 1% tolerances, you can pick a hand-matched set of 5 from a bag of 5% resistors. Use 1 of them for R2 and 4 in series for R1.

irwinr
 
Posts: 3
Joined: Tue Dec 17, 2013 2:01 pm

Re: Measuring 12V battery voltage

Post by irwinr »

I was looking at Radio Shack's website, and it's kind of hard to search by tolerance. The lowest I could find of a 12kohm and/or 3kohm was 2% tolerance.

Is there a better place to buy such specific parts?

Thanks,
-Jeremy

User avatar
adafruit_support_bill
 
Posts: 88096
Joined: Sat Feb 07, 2009 10:11 am

Re: Measuring 12V battery voltage

Post by adafruit_support_bill »

Mouser is usually my first stop. DigiKey has a huge selection also.

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Products from Adafruit”