Battery mah calculation

Hello,

I have a solar lipo charger application where I have 3 ACS 711 hall current sensors taking the current readings out of my solar panel, battery 1, and battery 2 every 5 seconds. These batteries are connected to the same source and are connected to a switch relay to ensure that they do not feed into each other due to its parallel connections.

I was looking to retrieve the net mah or some kind of graph representing the mah ratings at different times of the day. All I have retrieved is the current every 5 seconds, is there a way to represent the mah generated in a day? I have attached an image at the bottom of this post to represent the current vs time graph I am referring to.

Thank you

Two Parallel Adafruit Charger (WSL) [2020-06-12].png

Image from Original Post so we don't have to download it. See this Simple Image Posting Guide

944427f19e35b40f137513514e7ac67398eb9e6d.png

...R

For illustration if you assume that the mA reading is constant at 273mA during a 5 second interval then for that period you will have 273 * 5 milliamp seconds or 273 * 5 / 60 / 60 milliamp hours.

If you accumulate those values over time you will have the mAh produced or consumed during that time.

It would probably be a bit more accurate to assume the mA during a 5 second interval is the average of the new reading and the previous reading.

Solar panel output can vary very quickly in cloudy conditions and a more frequent measurement might be warranted.

...R

Hello iqasi096,
I did something similar but in my case for calculating the battery capacity based on discharge for a UPS. My measurements are taken every second, this is the for the capacity:

measurement_results[Batt_i].battery_Ah -= (measurement_results[Batt_i].calculated_value / 3600);

To explain, this is intended to calculate the capacity based on discharging the battery, which is why the current is shown as -ve. The division by 3600 reflects that there are 3600 samples per hour.

So, every second 1/3600 of the battery current gets added to the cumulative battery capacity.

[EDIT]
Ironically, while I was typing this one of my circuit breakers tripped meaning my UPS was supplying its intended load from the batteries. I suspect it might be something in the UPS that tripped the breaker because, although it is working, the mains monitor part seems to have died.
[EDIT EDIT]
Nothing wrong with the mains monitor circuit, don't know what tripped the breaker.

PerryBebbington:
Hello iqasi096,
I did something similar but in my case for calculating the battery capacity based on discharge for a UPS. My measurements are taken every second, this is the for the capacity:

measurement_results[Batt_i].battery_Ah -= (measurement_results[Batt_i].calculated_value / 3600);

To explain, this is intended to calculate the capacity based on discharging the battery, which is why the current is shown as -ve. The division by 3600 reflects that there are 3600 samples per hour.

So, every second 1/3600 of the battery current gets added to the cumulative battery capacity.

[EDIT]
Ironically, while I was typing this one of my circuit breakers tripped meaning my UPS was supplying its intended load from the batteries. I suspect it might be something in the UPS that tripped the breaker because, although it is working, the mains monitor part seems to have died.
[EDIT EDIT]
Nothing wrong with the mains monitor circuit, don't know what tripped the breaker.

Robin2:
For illustration if you assume that the mA reading is constant at 273mA during a 5 second interval then for that period you will have 273 * 5 milliamp seconds or 273 * 5 / 60 / 60 milliamp hours.

If you accumulate those values over time you will have the mAh produced or consumed during that time.

It would probably be a bit more accurate to assume the mA during a 5 second interval is the average of the new reading and the previous reading.

Solar panel output can vary very quickly in cloudy conditions and a more frequent measurement might be warranted.

...R

Perfect, just the feedback I needed! Thank you both very much

PerryBebbington:
Hello iqasi096,
I did something similar but in my case for calculating the battery capacity based on discharge for a UPS. My measurements are taken every second, this is the for the capacity:

measurement_results[Batt_i].battery_Ah -= (measurement_results[Batt_i].calculated_value / 3600);

To explain, this is intended to calculate the capacity based on discharging the battery, which is why the current is shown as -ve. The division by 3600 reflects that there are 3600 samples per hour.

So, every second 1/3600 of the battery current gets added to the cumulative battery capacity.

[EDIT]
Ironically, while I was typing this one of my circuit breakers tripped meaning my UPS was supplying its intended load from the batteries. I suspect it might be something in the UPS that tripped the breaker because, although it is working, the mains monitor part seems to have died.
[EDIT EDIT]
Nothing wrong with the mains monitor circuit, don't know what tripped the breaker.

On a side note, may i also see the rest of the code for future reference to your design please?

Robin2:
For illustration if you assume that the mA reading is constant at 273mA during a 5 second interval then for that period you will have 273 * 5 milliamp seconds or 273 * 5 / 60 / 60 milliamp hours.

If you accumulate those values over time you will have the mAh produced or consumed during that time.

It would probably be a bit more accurate to assume the mA during a 5 second interval is the average of the new reading and the previous reading.

Solar panel output can vary very quickly in cloudy conditions and a more frequent measurement might be warranted.

...R

I also very much appreciate your post on serial input basics. It helped me out a lot when i was first starting out with arduino telecommunications so thank you for that

iqasi096:
On a side note, may i also see the rest of the code for future reference to your design please?

Not wishing to seem unhelpful but no for a few reasons. The whole code is a complex project that I don't want to share or have to explain the workings of. It occupies 5 C and 5 header files, and I don't want to put that lot on here and it is not written for Arduino so does not really belong on this site. OK, so C is pretty universal but there are many things that are different to any Arduino you can think of because of the way ports and other peripherals are driven.
Sorry.