My library matches the tutorial as does my code below:
# SPDX-FileCopyrightText: Copyright (c) 2022 ladyada for Adafruit Industries
#
# SPDX-License-Identifier: Unlicense
import time
import board
import adafruit_max1704x
#i2c = board.I2C() # uses board.SCL and board.SDA
i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller
max17 = adafruit_max1704x.MAX17048(i2c)
print(
"Found MAX1704x with chip version",
hex(max17.chip_version),
"and id",
hex(max17.chip_id),
)
# Quick starting allows an instant 'auto-calibration' of the battery. However, its a bad idea
# to do this right when the battery is first plugged in or if there's a lot of load on the battery
# so uncomment only if you're sure you want to 'reset' the chips charge calculator.
# print("Quick starting")
# max17.quick_start = True
while True:
print(f"Battery voltage: {max17.cell_voltage:.2f} Volts")
print(f"Battery state : {max17.cell_percent:.1f} %")
print("")
time.sleep(1)
When running this code, I receive the following error in the Serial Viewer
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "adafruit_max1704x.py", line 114, in __init__
File "adafruit_max1704x.py", line 127, in reset
File "adafruit_register/i2c_bit.py", line 64, in __set__
OSError: [Errno 19] No such device
I opened the i2c_bit.py to see what was on line 64
def __set__(self, obj: I2CDeviceDriver, value: bool) -> None:
with obj.i2c_device as i2c:
i2c.write_then_readinto(self.buffer, self.buffer, out_end=1, in_start=1)
if value:
self.buffer[self.byte] |= self.bit_mask
else:
self.buffer[self.byte] &= ~self.bit_mask
i2c.write(self.buffer)`
Line 64 specifically is:
i2c.write_then_readinto(self.buffer, self.buffer, out_end=1, in_start=1)
I believe something has been changes recently in the adafruit_register library which is where the i2c_bit.py file is located.
I downloaded the library bundle:
adafruit-circuitpython-bundle-8.x-mpy-20221212
Bootloaded in use:
adafruit-circuitpython-adafruit_feather_esp32s3_tft-en_US-8.0.0-beta.5.uf2
This is my first attempt with this project as well as my first time reporting an issue. Please let me know if you need futher information.
I performed a brief search for this issue and did not see anything.
I am running CircuitPython v 8.0.0 beta 5 from 12-11-2022 I believe. Hardware is: Feather ESP32 S3 TFT PID# 5483 MAX17048 PID# 5580 - Adafruit MAX17048 LiPoly / LiIon Fuel Gauge and Battery Monitor - STEMMA JST PH & QT / Qwiic
I am following the Adafruit Learn guide here
My library matches the tutorial as does my code below:
When running this code, I receive the following error in the Serial Viewer
I opened the i2c_bit.py to see what was on line 64
Line 64 specifically is:
i2c.write_then_readinto(self.buffer, self.buffer, out_end=1, in_start=1)
I believe something has been changes recently in the adafruit_register library which is where the i2c_bit.py file is located.I downloaded the library bundle: adafruit-circuitpython-bundle-8.x-mpy-20221212 Bootloaded in use: adafruit-circuitpython-adafruit_feather_esp32s3_tft-en_US-8.0.0-beta.5.uf2
This is my first attempt with this project as well as my first time reporting an issue. Please let me know if you need futher information.