Created
May 4, 2018 08:10
-
-
Save daniel-j/aa7ab05683a2e36b92d64e249e884f61 to your computer and use it in GitHub Desktop.
Script to read the battery drain/charge rate of the GPD Pocket, outputs wattage. Negative is draining, positive is charging.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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