-
Notifications
You must be signed in to change notification settings - Fork 7.4k
drivers: sensors: Add driver for AHT20 temperature humidity sensor. #41702
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
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.
Did an initial review, there are quite a few issues that need to be addressed.
e665171
to
c047368
Compare
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.
Primarily the k_busy_wait concerns me
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 looks pretty good, the comments need to use /* */ rather than // though, and I believe checkpatch will fail on those.
If you plan on contributing a lot to zephyr I recommend setting up checkpatch as a git hook.
See https://docs.zephyrproject.org/latest/contribute/index.html#coding-style
bec19f6
to
406c47d
Compare
I used both clang-format and uncrustify to format my source code, but the space before the colon is introduced by uncrustify, if there is no proper tool to format code. I'm using version Uncrustify-0.72.0_f, is my version too old? Otherwise, it's better to fix the uncrustify config instead of modify the code format by hand. uncrustify --replace --no-backup -l C -c $ZEPHYR_BASE/.uncrustify.cfg aht20.c |
This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time. |
@RafaelLeeImg we are interested on this driver, do you have plan to continue with the PR !! |
Hi. uncrustify --replace --no-backup -l C -c $ZEPHYR_BASE/.uncrustify.cfg But, at the stage, the CI still complains coding formats error. |
CI failed due to fail to fetch packages. |
How to generate this symbol DT_HAS_ASAIR_AHT20_ENABLED ? |
^^ drop on kconfig. add vendor prefix in dts/bindings/vendor-prefixes.txt It seems humidity value is needs to be corrected according to datasheet it has to be multiplied by 100
|
I have wrote a test demo, the data format is right. Datasheet wrote RH[%]=(S_rh/2^20)*100%, 100% is 1.0. |
H.val1 = 0, H.val2 = 335938, T.val1 = 14, T.val2 = 633667; |
Add support of AHT20 Temperature and Humidity Sensor Signed-off-by: Rafael Lee <[email protected]>
Is there any further modifications required? |
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.
The compliance check failure still needs to be addressed
__ASSERT_NO_MSG(chan == SENSOR_CHAN_ALL || chan == SENSOR_CHAN_AMBIENT_TEMP || | ||
chan == SENSOR_CHAN_HUMIDITY); |
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.
Return an errno
|
||
#define AHT20_INIT(n) \ | ||
static struct aht20_data aht20_data_##n = { \ | ||
.bus = I2C_DT_SPEC_INST_GET(n), \ |
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.
Move this to a const config struct
@RafaelLeeImg ping |
This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time. |
Support AHT20 Temperature and Humidity Sensor with I2C bus
Webpage for the sensor is here:
https://asairsensors.com/product/aht20-integrated-temperature-and-humidity-sensor/
Data sheet v1.0.03 is here:
https://asairsensors.com/wp-content/uploads/2021/09/Data-Sheet-AHT20-Humidity-and-Temperature-Sensor-ASAIR-V1.0.03.pdf
Tested with physical sensor.
arm-none-eabi-gcc (15:10.3-2021.07-4) 10.3.1 20210621 (release)