# Measure 12V 35Ah battery level in arduino

I am building an arduino device controlling a solar power system. I am a beginner and would like to know what kind of part I would need to connect to the board to acheive this.

• Do you want to measure current flow in both direction too? Commented Dec 1, 2012 at 5:47
• yes I do that would be great can you advise a circuit? Commented Dec 1, 2012 at 5:55
• I could, if you give all the specs Commented Dec 1, 2012 at 6:58
• @Richman Thanks for your help, I added a new question electronics.stackexchange.com/questions/50332/… Commented Dec 1, 2012 at 17:08

If all you want to do is simply measure the battery voltage, then you just need to scale the voltage down with a simple resistive divider, then feed it into your ADC. You can add a zener to ground, or schottky to the 5V rail for input protection if you wish (assuming your Arduino runs from 5V, which I believe they do).

Basically it would look something like this:

Simulation:

Note the resistor values are not set in stone, they just need to be the correct ratio of 7:5. So you could pick 7kΩ and 5kΩ if you like, or similar. One thing to watch out for is the maximum input impedance your Arduino ADC can handle, which will be given in the datasheet - some are quite low (e.g. 10kΩ)
The maximum output impedance of your divider is the parallel resistance of both resistors, so with e.g. 10kΩ + 10k&omega the output impedance (at the divider centre) will be 0.25 * 10kΩ = 2.5kΩ.
With 7kΩ and 5kΩ the output resistance will be 1 / (1/7Ω + 1/5kΩ) = ~2.9kΩ (with the 70kΩ and 5kΩ it will be ~29kΩ)

• As I said Im just beginning, I understand the voltage division now. To be clear, does the size of the battery or the fact that the circuit drawing from it can go up to 20A impact the resistance of the resistors I need to use in the divider? Commented Dec 1, 2012 at 6:02
• The size of the battery doesn't matter - a 100mAh 12V battery will deliver the same current as a 5Ah 12V battery if they both see the same resistance. If the rest of the circuit draws up to 20A that doesn't matter either, as the divider will only allow the current according to the resistance of your divider. YOu can calculate the wattage rating for the resistors using I^2 * R (or V*I, same result) - e.g if you have 12V through your 7k + 5k divider, then 12V / 12k = 1mA. Then for each resistor, you have 1ma^2 * 7k = 7mW, and 1mA^2 * 5k = 5mW, so a standard 1/4W resistor would be fine for both. Commented Dec 1, 2012 at 6:17
• I suggest you grab a circuit simulator and play around with it a bit to get an idea of how changing values can affect things. LTSpice is my favourite (and it's free) Be sure to read the help well, it's a bit tricky to get started with but very powerful. Tip - hold down alt and click on a component to see it's power dissipation. You can simulate transient (signal over time) frequency (amplitude vs frequency) DC (DC node values) DC sweep (sweep a voltage source and see what happens to the V-I values) and much more. Commented Dec 1, 2012 at 6:29
• Won't the divider act as a constant load across the battery, even when everything else is switched "off"? You'd need to add a transistor between the pull down resistor and ground, to disable it, so this doesn't slowly drain the battery. Commented Oct 11, 2015 at 0:14