-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
AHT10: Use state machine to avoid blocking delay #6401
Conversation
I just updated my ESP32C3 with a AHT21 sensor to ESPhome 2024.3.0, it compiles fine, but the sensor doesnt seem to update anymore. Could it be related to this PR? |
It's possible. Do you have any logs? And yaml? |
There was another PR on this component, #6303 and I think there is an error in it. It's writing the wrong number of bytes in the init command. It works ok here on an aht20, but it's possible the 21 is affected. |
@heintjeput Add this to your yaml and retest - there are a couple of changes there. external_components:
- source: github://clydebarrow/esphome@aht10-1
refresh: 10min
components: [ aht10] |
Thanks, for your replies. I think you are correct that it was in the other PR, I stopped searching at the first PR in the release. The yaml is here.
I am trying your improvement now, it might work, but let me check properly. I do get a value now
However it is about 1 - 2 degrees higher than expected. |
The issue is solved for me. Thanks for the help. |
I wrote PR #6303, the only functional change I made was to include the Soft Reset command because my AHT10s were giving the communication failure error message after firmware updates. Per the datasheets, the Soft Reset command is only 1 byte, where as the Trigger Measurement command is 3 bytes. PR #6401 seems to have introduced a regression because my sensors began reporting the comms failure after updating their firmware: [12:50:15][C][aht10:164]: AHT10:
[12:50:15][C][aht10:165]: Address: 0x38
[12:50:15][E][aht10:167]: Communication with AHT10 failed! @clydebarrow I added your branch to my yaml file and that seems to have resolved the issue. After firmware update my AHT10s are no longer reporting the comms failure and are sending out data again. |
Yes, but your PR writes 4 bytes as it takes size of a pointer instead of the data array. That tested ok on my AHT20, but might have different effects on other devices, and the value of the extra byte written is undefined so might vary from build to build as well. #6409 based on the branch you tested fixes that. |
🤦♂️ Doh! You're right. That probably did break it. When I was writing #6303 I tried reducing the size of the Initialization command because the datasheets don't specify that it's 3 bytes, and when I did it failed. |
What does this implement/fix?
The
aht10
sensor uses delays inupdate()
to wait for the chip to become ready to read. This causes unacceptable blocking of theloop()
thread.This PR replaces the in-line delays with scheduled callbacks to eliminate the thread blocking.
Types of changes
Related issue or feature (if applicable): fixes
Pull request in esphome-docs with documentation (if applicable): esphome/esphome-docs#
Test Environment
Example entry for
config.yaml
:Checklist:
tests/
folder).If user exposed functionality or configuration variables are added/changed: