I'm attempting to build a battery monitor

As the title says.

I have an Uno, 3x Acs712-30a current sensors from spark fun, a voltage divider to drop the voltage of the aux battery setup from 15v(max is 14.7 when deep cycle charger is charging) and the robot LCD TFT display.

I have them wired up easy enough and sensors work I can read values and display them on screen etc.

Now to where I need help. The programming.

Obviously using the voltage divider alone I can (very roughly) estimate state of charge. However voltage changes on load and at rest.

My setup is I have 1 input, a battery charger which will run current through sensor 1 to charge the battery. I have 2 12v accessory sockets each wired on its own circuit run through its own current sensor (sen 2 & 3).

I want to be able to monitor power in, power out and rate of discharge vs rate of charge and display a more accurate level of charge and estimate accurately (to within 30 mins or so) the remaining time till complete discharge at the current rate. I would also like to have access to usage stats like avg consumption per hour for each socket and instantaneous current usage for each socket. I will be putting some buttons to control menu scrolling.

My real question is how to gather, store and handle the power in, power out and calculate estimated time to discharge using a smoothed out discharge rate. Maybe recalculated in 1 minute cycles to smooth out timing.

Should I use an array stored on the microsd card? I'm not really sure how to approach this.

Thanks in advance.
Jason.

I presume you are talking about a lead-acid battery, and I presume you are talking about a system in which the battery is discharged deeply fairly often (i.e. not just on the odd occasion of a mains failure).

Accurately measuring/calculating the state of charge is very very difficult and more art that science. The guy who designed this Smartgauge claims to do it better than anyone else. There is a quite a lot of info on his website - but is method is proprietary. The Smartgauge only measures voltage.

I am NOT recommending his product (neither am I rubbishing it). He and I have had differences of opinion on another forum.

The first problem is what is meant by 100% discharge. It is totally impractical to draw 100Ah from a 100Ah battery - it would probably damage it if done more than once or twice.

If that isn't complication enough, how to you tell when it is fully charged?

And you have to allow for the inefficiency of energy storage in a battery. One amp-hour in is not the same as one amp-hour out.

...R

Thanks for the link.

Okay so me the purpose of this project,

Fully charged will be anything above 13.2v. The battery charger will float the AGM battery at 13.6-13.8v when fully charged.

I am yet to do some data logging during the 5 phases of the charging cycle to assess what the voltage and current do so i can then infer timing and charge cycle stage from the voltage and current actions.

During the DESULPHATION stage, voltage and current spikes occur at regular inverse intervals
then the BULK phase there is high current applied while voltage is slowly raised to max (14.4)
then the ABSORPTION phase the max voltage (14.4) is held while the current slowly fades away
then the FLOAT phase holds the float voltage at around 13.6 - 13.8 with very little current input.
then the PULSE stage just monitors the battery applying pulses of current when needed.

So with the current sensor on the input side i can monitor what stage the charger is in and assess battery level from there.

Next I want to watch the current draw on the 2 outlets and monitor the voltage. I can then see that X amps have been removed from the battery in Y time and that has caused the voltage to drop from A (time at when voltage was measured) to B (current comparative voltage) and then estimate with a degree of accuracy at what time my battery will be flat. (20% charge left 11.8v is lowest i can safely continually take this battery down to according to the specs)

That is my idea. I don't need it to be mobile phone accurate I just want it to be decent enough. Its for an Auxiliary power pack that runs fridge and lights when I go camping.

Using a voltage only measurement, i will have to run some tests logging 100% charge to 80% DoD at various rates, C100, C50, C20 and C10 to map the discharge voltage curves.

Using this library (maybe) the Kalman Filter could reasonably accuratley monitor and predict what i need. Im yet to keep reading that thread (glad i found it, didn't want to have to make my own filter!) to see if its the right choice for me.

You haven't provided any information on the charge/discharge cycles that you have in mind. For how many hours per day will the battery be on charge or is it meant to run for several days without charge and then be on charge for 24 or 48 hours. If it is receiving a daily charge how many days will you be using it while camping - 2 or 3 days or 2 or 3 weeks, or more?

I have a boat without a mains connection so all the (very expensive) charge energy is provided by a diesel engine or my solar panels.

To use voltage as an indicator of the state of charge a battery needs to be left disconnected and unused for 12 hours or more to allow the internal charge to even out. That's just not practical while you are using the battery so a lot of the monitoring data will have a large margin of error. It will overestimate the level of discharge while the battery is discharging and it will overestimate the level of charge when the battery is charging.

If your battery supplier says that it is safe to discharge down to 11.8v you need to find out the discharge current at which that voltage is measured.

Unfortunately battery manufacturers seem to be extraordinarily optimistic folks.

...R

Well it is charged while my car is in motion, then discharging when left stationary. So its hard to state how many partial charges it will get during extended trips. Maybe 2 maybe 10. Eventually I will have solar panels for the charger so it will have charge during the day.

jasonson:
So its hard to state how many partial charges it will get during extended trips. Maybe 2 maybe 10.

That's not giving me enough information. For example do you mean 2 charge periods in 10 days (at one extreme) and 10 charge periods in 10 days at the other extreme? Or what?

From the information you have given so far my impression is that you need to establish a battery management regime before you consider what way an Arduino might be able to assist you.

I presume you have made an estimate of how many amp-hrs you want the battery to provide between chaarges - perhaps you can tell us.

Then you need to figure if the charge period is long enough to put all that energy back into the battery allowing for charge inefficiency.

When the battery gets to about 75% charge its ability to accept charge current will have fallen dramatically so that the last 25% (indeed the last 10%) may take a number of hours of charging. If you are using the battery every day for a few days it won't matter if it is not charged to 100% every day but, if it is not, it won't be able to deliver as many amp-hrs. For the long term health of the battery it should be fully charged (for about 8 hours continuously) about once per week.

Using measurements to predict the available capacity in the battery if it is not being fully charged at every charge occasion is almost no better than guessing. As you mentioned earlier, it is feasible to have a low-voltage detection system but, of course, when that triggers it just means the battery is effectively empty.

Of course I may be over-complicating everything. Maybe all you want to do is take a fully charged 200Ah battery away for a weekend, use (say) 100Ah from it, bring it home and recharge it. Whereas I am assuming you want to use the battery for an extended period (or for a heavier load) so that it will have to be recharged while you are away for it to be any use.

...R