Closed leighghunt closed 2 years ago
Runs on restart with cron tab Appends to log.csv in same dir as file in format: yyyy-mm-dd hh:mm:ss, battery%, temperatureInCelsius
print('Logging...')
from pijuice import PiJuice
import time
import os
pj = PiJuice(1, 0x14) #?
log = f'{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())}, {pj.status.GetChargeLevel()["data"]}, {pj.status.GetBatteryTemperature()["data"]}\n'
outFile = os.path.dirname(os.path.realpath(__file__)) + '/log.csv'
with open(outFile, 'a') as f:
f.write(log)
print('Logging complete')
Log battery power remaining, and temperature to a CSV log file.
Possibly helpful links: