sensors: minor cleanup, bugs fixed, use unsigned long for discharged integration to avoid rounding errors.