-
Notifications
You must be signed in to change notification settings - Fork 11
Calibration patch for newer AHT20's #16
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
Conversation
Updating calibration function so that it isn't required to pass for newer AHT20's. This same change was made for the [Arduino library](adafruit/Adafruit_AHTX0#13)
|
Tested with the library example (although with an older AHT20) and ran as expected. Also added |
| i2c.write(self._buf, start=0, end=3) | ||
| while self.status & AHTX0_STATUS_BUSY: | ||
| time.sleep(0.01) | ||
| if not self.status & AHTX0_STATUS_CALIBRATED: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
keep this part in!
adafruit_ahtx0.py
Outdated
| self._buf[1] = 0x08 | ||
| self._buf[2] = 0x00 | ||
| with self.i2c_device as i2c: | ||
| i2c.write(self._buf, start=0, end=3) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this may fail, so do a try/except pass here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wrap only the call that can fail, please!
i2c.write(self._buf, start=0, end=3)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ladyada ohh okay, will fix. one question though- in __init__ if calibration returns False then it raises a RuntimeError, should that be changed too to not raise an error? or would the sensor read the SENSOR_CALIBRATED bit with the try/except and not return False?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
👋 Thanks for this pull request! Unfortunately, it looks like the automated continuous integration (CI) test(s) failed. These can be tricky to fix so we've written a guide on how to fix them locally. It has pages about running pre-commit locally and another about building the docs locally with sphinx. Thanks for contributing to CircuitPython! If you have more questions, feel free to join the Adafruit Discord and post in #circuitpython-dev. |
|
@ladyada would you be able to test this with a "new" AHT with the funky behavior? otherwise, LGTM, simple catch all exception pass |
Updating https://github.com/adafruit/Adafruit_CircuitPython_AHTx0 to 1.0.19 from 1.0.18: > Merge pull request adafruit/Adafruit_CircuitPython_AHTx0#16 from adafruit/aht20_calibration > "fix rtd theme " Updating https://github.com/adafruit/Adafruit_CircuitPython_Bundle/circuitpython_library_list.md to NA from NA: > Updated download stats for the libraries

Updating calibration function so that it isn't required to pass for newer AHT20's. This same change was made for the Arduino library