Calculating charging current
Skip the squaring. You are trying to integrate current, not power. And don't bother limiting the low values, either. Just sum them up, multiply by time between samples, and divide by total time.