Simple test

Ensure your device works with this simple test.

examples/lc709203f_simpletest.py
 1# SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries
 2#
 3# SPDX-License-Identifier: Unlicense
 4
 5import time
 6import board
 7from adafruit_lc709203f import LC709203F
 8
 9print("LC709203F simple test")
10print("Make sure LiPoly battery is plugged into the board!")
11
12i2c = board.I2C()  # uses board.SCL and board.SDA
13# i2c = board.STEMMA_I2C()  # For using the built-in STEMMA QT connector on a microcontroller
14sensor = LC709203F(i2c)
15
16print("IC version:", hex(sensor.ic_version))
17while True:
18    try:
19        print(
20            "Battery: %0.3f Volts / %0.1f %%"
21            % (sensor.cell_voltage, sensor.cell_percent)
22        )
23    except OSError:
24        print("retry reads")
25
26    time.sleep(1)

Thermistor test

Example showing the use of thermistors over I2C

examples/lc709203f_thermistortest.py
 1# SPDX-FileCopyrightText: 2021 Daniel Griswold
 2#
 3# SPDX-License-Identifier: MIT
 4
 5import time
 6import board
 7from adafruit_lc709203f import LC709203F
 8
 9print("LC709203F thermistor test")
10print("Make sure a thermistor is connected to the board!")
11
12i2c = board.I2C()  # uses board.SCL and board.SDA
13# i2c = board.STEMMA_I2C()  # For using the built-in STEMMA QT connector on a microcontroller
14sensor = LC709203F(i2c)
15
16# check your NTC thermistor datasheet for the appropriate B-Constant
17sensor.thermistor_bconstant = 3950
18sensor.thermistor_enable = True
19
20print("IC version:", hex(sensor.ic_version))
21while True:
22    print("Cell Temperature: %0.2f C" % (sensor.cell_temperature))
23    time.sleep(1)