Parts for battery measuring?

Hello

What electronics do I need to be able to measure battery voltage and temperature and how do I connect them?
I have an Arduino Mega and my battery size is 24V/100Ah

Thanks

Voltage can be sensed using a resistive divider to bring the 24V down to under 5V,
something like a 6:1 divide ratio would be appropriate, try 47k/10k in the first instance.

There are various kinds of temp sensor, analog and digital. Digital ones are a bit more
robust from noise etc and the commonly used example is the DS18B20. You will need
to place the temperature sensor in thermal contact with what its measuring, perhaps
using a small metal tube that can be placed in contact with the batteries.

Digital volt meter and a thermometer :slight_smile:

Or if you want the arduino to read the voltage a couple of resistors to suit an input voltage or around 32 volts (the battery exceeds 24 when being charged). Say a ratio of 5.4 to 1, so probably a 2k2 and a 12k. These ratios do not give an exact 32volt range, but near enough using standard components to permit you to trim in the range in the algoritm. You will of course also need a means of powering the arduino. This could come from the 24v supply but you would need something like a 36-to-5 volt DC power module.

If you want to also log temperature then I suggest you read the following for an example

I wonder why you want to read battery temperature if you are not reading battery acid SG. Capacity is primarily electrolyte temperature and SG dependant, voltage being a secondary variable and not a good indication of capacity.

Thank you for your answers.

jackrae:
Or if you want the arduino to read the voltage a couple of resistors to suit an input voltage or around 32 volts (the battery exceeds 24 when being charged). Say a ratio of 5.4 to 1, so probably a 2k2 and a 12k. These ratios do not give an exact 32volt range, but near enough using standard components to permit you to trim in the range in the algoritm.

You will of course also need a means of powering the arduino. This could come from the 24v supply but you would need something like a 36-to-5 volt DC power module.

If you want to also log temperature then I suggest you read the following for an example
Example Projects | TMP36 Temperature Sensor | Adafruit Learning System

I wonder why you want to read battery temperature if you are not reading battery acid SG. Capacity is primarily electrolyte temperature and SG dependant, voltage being a secondary variable and not a good indication of capacity.

Yes I want the Arduino to measure the battery. The batter is of closed AGM type.

MarkT:
Voltage can be sensed using a resistive divider to bring the 24V down to under 5V,
something like a 6:1 divide ratio would be appropriate, try 47k/10k in the first instance.

There are various kinds of temp sensor, analog and digital. Digital ones are a bit more
robust from noise etc and the commonly used example is the DS18B20. You will need
to place the temperature sensor in thermal contact with what its measuring, perhaps
using a small metal tube that can be placed in contact with the batteries.

Can you elaborate why I need a devider and how it works? Really I dont understand the answers. Where did the 12k/2.2k or 47k /10k resistor come from, why 2 different sized resistors and how should I connect them to my batteries? Is the 5V due to the input voltage for Arduino?

Once again, Thanks
DellBell

See the Wikipedia article on Voltage Divider. It's an important topic to understand since you'll be seeing it frequently.

47K/10K was suggested because the values are high enough that they won't waste a lot of battery power but not so high that the Arduino sees enough current to get a good reading; resistances over 10K tend to yield less accurate results.

I am new to the forum and electronics. I hope that I am not breaking etiquette but I have a related question concerning a voltage divider and thought the OP might benefit as well from answers:

Also measuring a vehicle battery with the intention of building a voltmeter.
Using a Nano and breadboard to start, I have a divider with 1/2w 330k (measured) and 97k(measured) resistors.
Measured input from divider on Nano's A2
Powering the divider and Nano from a variety of sources;
5.05 v from USB (not the micro USB input) via BB and then into +5
9v battery into Vin
DC power (15.4 v measured) into Vin

Holding the divider side steady and using different power sources for the Nano provides different results when viewed on a serial monitor. For example, the 15.4 v DC source on the divider produces divided values of 703, 711, and 723 as the input values to A2 when powering the Nano via the DC, USB and 9v. respectively.

I am puzzled as to why and would like to figure a solution to produce consistent results.
Thanks all for your help.

The default analog reference setting compares voltages as a ratio of VCC. What you're seeing is the slight variance in voltage of the 5V when powering from USB or from the onboard linear regulator. The linear regulator would theoretically output the same voltage from either the 9V battery or 15.4V source, but linear regulators are affected by both the input voltage and heat which will cause some variance in their regulation.

For more accurate readings you can either scale the battery voltage to the 0-1.1V "internal" reference or use an external voltage reference. A TL431 would be an example of an external reference but there are many (and more precise/expensive) options out there.

I'm assuming your values of 703, 711, and 723 values are averages from multiple readings. The 330K/97K values of your resistors are going to cause the ADC to have some difficulty getting a stable reading.

Thank you, Chagrin.

Yes, those are averages. I've chosen those resistors in an attempt to reduce heat - I'm using a 2 x 4 x 1 project box on a motorcycle. I've also scaled them to come as close to 5v from the divider without exceeding it under possible peak scenarios; logic being that the smaller my ratio to gross up from the A2 reading to the inferred "true" battery voltage, the more accurate the inferred voltage will be. (I should possibly re-examine this idea.)

Time for me to find out about TL431s...

If you're just measuring steady-state DC of the battery, try putting about a 10uF tantalum capacitor between the A/D input and ground. The A/D is a sampled device and ideally wants to be driven by a low impedance. That's why in higher-resolution applications you can find OP-Amps specifically designed to drive an A/D. If you have the board space and can afford the op-amp use something like an LMC662 which is a dual Rail-Rail device. Put it immediately after the voltage divider and connect it as a unity gain follower.

BobAgain:
Thank you, Chagrin.

Yes, those are averages. I've chosen those resistors in an attempt to reduce heat -

That equates to 0.5mW ie one half of one thousandth of a watt. Are you serious ?

Chagrin:
See the Wikipedia article on Voltage Divider. It's an important topic to understand since you'll be seeing it frequently.

47K/10K was suggested because the values are high enough that they won't waste a lot of battery power but not so high that the Arduino sees enough current to get a good reading; resistances over 10K tend to yield less accurate results.

Ok, now I know that too, thanks. I'm guessing that the Arduino analog input is the thing that will give me the information. However, there is one thing that I'm unsure of. know that the higher the resistance the less effect wasted, however this also means that the current gets smaller and smaller. eventually, if the current for both the analog Arduino input and the resistor connected to the ground are getting equal in size, the Vout from the voltage divider will not be accurate.

So, how do I find the appropriated resistor size for the divider? 47k/10k and 12k/2.2k were suggested, but what were they based on?

As always, Thanks
-DellBell

2.2k and 12k were based on using readily available resistors to produce a voltage drop ration of 6.45 :1 ie 32/6.45 = 4.96 (approx 5volts). So with 5 volts input to the Arduino developed across the 2.2k resistor, the remainder of the 32 volts ie 27 volts will be dropped across the 12k resistor. I chose 32 volts as a maximum charge voltage of your 24 volt battery. Others might say these resistor values are a bit low and cause excessive current drain on the battery. However consider that 14.2k places a 1.7mA load on the battery, which being rated at 100AH should be capable of feeding this for in excess of 7 years !! I think self-discharge and other circuits will far exceed this trivial burden.

jackrae:
2.2k and 12k were based on using readily available resistors to produce a voltage drop ration of 6.45 :1 ie 32/6.45 = 4.96 (approx 5volts). So with 5 volts input to the Arduino developed across the 2.2k resistor, the remainder of the 32 volts ie 27 volts will be dropped across the 12k resistor. I chose 32 volts as a maximum charge voltage of your 24 volt battery. Others might say these resistor values are a bit low and cause excessive current drain on the battery. However consider that 14.2k places a 1.7mA load on the battery, which being rated at 100AH should be capable of feeding this for in excess of 7 years !! I think self-discharge and other circuits will far exceed this trivial burden.

I see. Do you know how much current the Arduino analog input drains or where I can find that myself for my Arduino Mega?

Just something I noted right now is that MarkT suggested a 6:1 divider, but a 47K/10K which is 4.7 : 1 and you suggested a 12k/2.2k which is 5.45 and not 6.45. Is there something stupid I'm not getting here? :stuck_out_tongue:

OK, let's look at it in basic terms and see how my original calculations evolved.

Battery voltage is 32 (my figure) and you want to feed the Arduino with only 5 volts so divisor ratio is basically 32/5 = 6.4

Now, let us say we have a resistor divider chain with R1 coming from the battery positive terminal coupled to a second resistor R2, the free end of which is coupled to the battery negative terminal (and the arduino ground terminal). The junction of the two resistors is connected to the arduino input terminal. Let us say the value of R2 is 2.2k. We know this has to develop 5 volts across it so the current flowing through it must be 5/2200 = 2.273mA. The input impedance of the arduino is very high so we can assume no current flows into that point. So 2.273mA also flows through R1 and this resistor has to drop (32-5) = 27volts. So the value of R1 = 27 /2.273 = 11.88k.

These resistors have the ration of 11.88/2.2 = 5.4 which obviously does not correspond to the original divisor number of 6.4 but is actually the ratio of the two resistors required to create the desired input to the arduino

However, if we add the chain values 11.88k + 2.2k = 14.08k (R1 +R2) and divide this number by the lower resistor 2.2k (R2) we have 14.08/2.2 = 6.4 which is the ratio of the input voltage to output voltage.

Confused ? I'm not surprised.

jackrae:
Confused ? I'm not surprised.

Not really that much. I've had this in the college for 6 years ago, so I recall some parts of it :stuck_out_tongue: I just need to chew a bit more on it. Can I ask for help with the programming part too? Just the basic like in a pseudo code and what libraries I need to measure the temp and voltage.

Just to be clear, I need only these parts: DS18B20 and 2 resistors right?

Best regards,
-DellBell