Last active
August 4, 2019 10:58
-
-
Save ebith/640a23f7fefe4464a1dc4f68a5272260 to your computer and use it in GitHub Desktop.
mackerel plugin for UPS-Lite
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/env python3 | |
import time | |
import smbus | |
i2c = smbus.SMBus(1) | |
addr=0x36 | |
data = i2c.read_i2c_block_data(addr, 0x04, 2) | |
capacity = int((data[0] << 8 | data[1]) / 256) | |
print(f'battery.capacity\t{capacity}\t{time.time()}') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment