Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Script to read the battery drain/charge rate of the GPD Pocket, outputs wattage. Negative is draining, positive is charging.
#!/usr/bin/python3
dir='/sys/class/power_supply/max170xx_battery/'
with open(dir + 'current_avg', 'r') as f:
current = int(f.read()) / 1000000.0
with open(dir + 'voltage_avg', 'r') as f:
voltage = int(f.read()) / 1000000.0
wattage = voltage * current
# print('{0:.2f}V {1:.2f}A {2:.2f}W'.format(voltage, current, wattage))
print('{0:.2f}W'.format(wattage))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment