In a DC to AC inverter set, the in/out current of a battery could be periodic (mainly during its charging) or real DC (if discharged by a DC load, as LEDs connected directly to it).
Let us assume an MCU of a current meter measures the battery current every 104 usec. The MCU, I have, is ATmega8A.
What could be the optimum algorithm (no need for details) to find out the ‘average’ current from the measured samples? (during practical intervals, about 1/2 sec, and without adding a synchronising circuit)
Please note that in case of charging (by the mains) or discharging (by a DC to AC inverter), the frequency is usually not known (around the nominal one) and likely varies continuously (mainly of the relatively small private AC generators).