i2c = board.I2C()
while not i2c.try_lock():
pass
i2c_address_list = i2c.scan()
i2c.unlock()
device = None
if 0x0b in i2c_address_list:
lc709203 = LC709203F(board.I2C())
# Update to match the mAh of your battery for more accurate readings.
# Can be MAH100, MAH200, MAH400, MAH500, MAH1000, MAH2000, MAH3000.
# Choose the closest match. Include "PackSize." before it, as shown.
lc709203.pack_size = PackSize.MAH400
device = lc709203
elif 0x36 in i2c_address_list:
max17048 = MAX17048(board.I2C())
device = max17048
else:
raise Exception("Battery monitor not found.")
while device:
print(f"Battery voltage: {device.cell_voltage:.2f} Volts")
print(f"Battery percentage: {device.cell_percent:.1f} %")
print("")
time.sleep(1)
ENable pin
If you'd like to turn off the 3.3V regulator, you can do that with the EN(able) pin. Simply
tie this pin to Ground and it will disable the 3V regulator. The BAT and USB pins will
still be powered.
©Adafruit Industries Page 34 of 263