Skip to content

Instantly share code, notes, and snippets.

@ebith

ebith/batteryCapacity.py

Last active Aug 4, 2019
Embed
What would you like to do?
mackerel plugin for UPS-Lite
#!/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
You can’t perform that action at this time.