Battery lavel indicator

I trying to make a battery voltage indicator for the 48 v battery of an ev.

I simply make voltage divider cricuit and measure voltage by analog read function. It show real velue when ever no load apply. When load is connected to battery the voltage fluctuations accur .

So how to measure battery capacity of a battery no mettars load is applied or not

Voltage over any source will change every time you connect your load, you just can't help that. Depending of the load current and battery capasity, the difference can be very wide.

You should test your knowledge about the nature of the electricity and electric components, you will understand better after some theory studying.

Cheers,
Kari

"Measuring state-of-charge by voltage is simple, but it can be inaccurate because cell materials and temperature affect the voltage. The most blatant error of the voltage-based SoC occurs when disturbing a battery with a charge or discharge. The resulting agitation distorts the voltage and it no longer represents a correct SoC reference. To get accurate readings, the battery needs to rest in the open circuit state for at least four hours; battery manufacturers recommend 24 hours for lead acid. This makes the voltage-based SoC method impractical for a battery in active duty.
Each battery chemistry delivers its own unique discharge signature. While voltage-based SoC works reasonably well for a lead acid battery that has rested, the flat discharge curve of nickel- and lithium-based batteries renders the voltage method impracticable." The above is from BU-903: How to Measure State-of-charge - Battery University. This response is to help you get started in solving your problem, not solve it for you.
Good Luck & Have Fun!
Gil

Battery capacity can be estimated by completely discharging the battery using a fixed load, measuring the time and summing the current to get Ampere hours. The capacity will drop as the battery ages, or the load increases.

Once you have an estimate of the capacity, measure and sum the load current as a function of time, then subtract from the capacity to estimate remaining charge level.

Low battery voltage is a great indicator of a drained battery.
Current battery voltage is not a good indicator of how much charge is left in a battery - especially if that battery is under load, even more so if it's a varying load. Battery voltage (measured open circuit or with trivial load) tends to drop quite quickly in the first 10-20% of charge, then remain rather constant until the last 10-20% when it starts to drop fast again.

Some types of battery have a flat discharge curve, and monitoring just the voltage will not reliably tell you state-of-charge, you have to integrate the current (Coulomb counter).