code.py
 1  # SPDX-FileCopyrightText: 2021 Kattni Rembor for Adafruit Industries
 2  # SPDX-License-Identifier: MIT
 3  """
 4  CircuitPython Simple Example for LC709203 Sensor
 5  """
 6  import time
 7  import board
 8  from adafruit_lc709203f import LC709203F, PackSize
 9  
10  # Create sensor object, using the board's default I2C bus.
11  battery_monitor = LC709203F(board.I2C())
12  
13  # Update to match the mAh of your battery for more accurate readings.
14  # Can be MAH100, MAH200, MAH400, MAH500, MAH1000, MAH2000, MAH3000.
15  # Choose the closest match. Include "PackSize." before it, as shown.
16  battery_monitor.pack_size = PackSize.MAH400
17  
18  while True:
19      print("Battery Percent: {:.2f} %".format(battery_monitor.cell_percent))
20      print("Battery Voltage: {:.2f} V".format(battery_monitor.cell_voltage))
21      time.sleep(2)