Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recent AHT20 shipment Errno 19 (ENODEV) retrieving device status fails in ahtx0_simpletest.py #18

Closed
boltonja opened this issue Dec 9, 2023 · 5 comments

Comments

@boltonja
Copy link

boltonja commented Dec 9, 2023

Ordered some new AHT20 breakout boards on 26 Nov 2023. The first two of these devices (others remain sealed) fail in status with CircuitPython 8.2.9 and Adafruit CircuitPython Bundle 20231205:

Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.
code.py output:
Traceback (most recent call last):
  File "code.py", line 17, in <module>
  File "adafruit_ahtx0.py", line 96, in __init__
  File "adafruit_ahtx0.py", line 120, in calibrate
  File "adafruit_ahtx0.py", line 129, in status
OSError: [Errno 19] No such device

Code done running.

Expected output is:

Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.
code.py output:

Temperature: 26.5 C
Humidity: 32.9 %

Temperature: 26.4 C
Humidity: 33.0 %

Temperature: 26.2 C
Humidity: 33.1 %

This is the line 129 in the library that is failing:

def status(self) -> int:
        """The status byte initially returned from the sensor, see datasheet for details"""
        with self.i2c_device as i2c:
            i2c.readinto(self._buf, start=0, end=1)  ### line 129
        # print("status: "+hex(self._buf[0]))
        return self._buf[0]

There are several revisions of the data sheet floating around on the internet. The one linked on the Adafruit Product site says the minimum wait time after power on is 100ms. Other documentation that I have found e.g., from Sparkfun indicate 20ms and a sample C program that I found on the manufacturer's product page waits 500ms after power-on.

I increased wait time to 110ms in a copy of adafruit_ahtx0.py, without any improvement in status reading. I also tried commenting out the self.reset() invocation in init() because the literature seems to indicate it might be unnecessary. Here is the snippet with my change:

    def __init__(
        self, i2c_bus: busio.I2C, address: int = AHTX0_I2CADDR_DEFAULT
    ) -> None:
        time.sleep(0.110)  # 20ms delay to wake up
        self.i2c_device = I2CDevice(i2c_bus, address)
        self._buf = bytearray(6)
#        self.reset()
        if not self.calibrate():
            raise RuntimeError("Could not calibrate")
        self._temp = None
        self._humidity = None

    def reset(self) -> None:
        """Perform a soft-reset of the AHT"""
        self._buf[0] = AHTX0_CMD_SOFTRESET
        with self.i2c_device as i2c:
            i2c.write(self._buf, start=0, end=1)
        time.sleep(0.110)  # 20ms delay to wake up

Let me know how I can help? More context in a forum thread here

@boltonja
Copy link
Author

boltonja commented Dec 9, 2023

I'm not sure what I'm doing wrong with the code formatting tool, but if anything is unclear please reach out.

@DemiVis
Copy link
Contributor

DemiVis commented Dec 15, 2023

I believe that this issue is a misdirecting error message bubbling up from the depths. I ran into it too (see #17 )

If you'd like, feel free to try out the modified version I made (#19) and let us know if that works to support the pull request (or not so we can fix it!)

@mikeysklar
Copy link

@DemiVis thank you for mentioning PR #19. I just tested and it worked smoothly for me. I was also getting the No such device error with the current release AHTx0 1.0.20 CircuitPython library.

Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.
code.py output:
Traceback (most recent call last):
  File "code.py", line 15, in <module>
  File "adafruit_ahtx0.py", line 96, in __init__
  File "adafruit_ahtx0.py", line 120, in calibrate
  File "adafruit_ahtx0.py", line 129, in status
OSError: [Errno 19] No such device

After applying PR#19 update:

Adafruit CircuitPython 8.2.9 on 2023-12-06; Adafruit QT Py ESP32-S3 no psram with ESP32S3
>>>
>>>
soft reboot

Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.
code.py output:

Temperature: 20.1 C
Humidity: 45.0 %

@ladyada
Copy link
Member

ladyada commented Dec 18, 2023

hopefully resolved by merging
#19
mpy and pypi will take a day to update!

@ladyada ladyada closed this as completed Dec 18, 2023
@boltonja
Copy link
Author

#19 works for me, too!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants