Python code to monitor and log battery data