-
Notifications
You must be signed in to change notification settings - Fork 869
Updated aht20 driver to use thread safe api from idf>=5.4. (AEGHB-1062) #503
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
base: master
Are you sure you want to change the base?
Conversation
👋 Hello jeetrohan, we appreciate your contribution to this project! Click to see more instructions ...
Review and merge process you can expect ...
|
Hi @jeetrohan , thanks for your contribution! |
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.
Hi, @jeetrohan , thanks for your contribution! Before making a commit, you can install pre-commit to ensure that your code style is consistent with the repository.
pip install pre-commit
pre-commit install --allow-missing-config -t pre-commit -t commit-msg
-path: ../../../../examples/sensors/aht20_demo | ||
|
||
dependencies: | ||
idf: ">=5.4" |
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.
Forcibly restricting the component in version 5.4 will make it difficult for many existing users of this component to accept. Perhaps the i2c_bus component can be used to manage the entire I2C, since i2c_bus will automatically switch to the esp_driver_i2c driver in version 5.3 and above.
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.
Hi @YanKE01 There are two reasons I had originally decided to use idf>=5.4.
-
The new I2C APIs introduced in this version are thread-safe, at least when multiple threads are not accessing the same device/sensor. Basically multiple devices can be accessed safely on same I2C bus, without contention from different threads.
The new I2C APIs, if I remember correctly, introduced in idf-5.2 are incompatible with older ones(idf<5.2), so it should not affect much the users who are using the new APIs, as they are likely to update sooner than later. -
I had assumed that using the Generic I2C driver APIs provide more flexibility to this driver, even when used without this repository (such as component registry, though I might be uninformed on this part, as component registry resolves all the dependencies).
However, considering only this repository, and taking into account your suggestion.. I've concluded that there are two feasible things that can be done...:
-
I simply do as have been suggested. Replace the driver to i2c_bus component. This will effectively strip the thread-safety for any users, not using idf>=5.4(A note can be placed in this regard in README section).
The dependency in this case, If my understanding is correct, will change to idf>=4.3. -
We release two versions of this driver. One with the i2c_bus component (v1.1.0) and other with esp_driver_i2c (v2.0.0) as the older i2c driver and its APIs are just a legacy support feature.
A relevant note from idf 5.2.5 documentation (& still in idf.5.4.1) : "Please keep in mind that the legacy driver is now deprecated and will be removed in future."
This was the reason to refer this as v2.0.0; to indicate that it is not meant to support legacy driver.
While you finalize the decision.. I'll prepare both the versions.
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.
Hi, @jeetrohan , in the current repository, we are standardizing the use of i2c_bus
to manage I2C-type sensors, so I believe using i2c_bus
would be a better decision. Moreover, i2c_bus
was designed with thread safety in mind from the beginning, so users don't need to worry about concurrency issues.
As for the AHT20, which is a commonly used component, its upgrade cannot simply switch to the latest version of the IDF (ESP-IDF), because we need to consider the versions being used by current users. If we force the use of the latest IDF, users who are still on versions earlier than IDF 5.4 will no longer be able to use the AHT20 component.
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.
Hi @YanKE01
I've updated the most recent submission to use the i2c_bus.
Yes, I understand the support for previous idf is still valid.
|
||
printf("AHT20 deinitialized\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.
Memory leak checks have not been performed. It might be better to make modifications based on the original test_apps
, since CI-related issues are also involved.
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.
I've updated this locally, waiting for your decision on the other recommendation.
@@ -1,5 +1,9 @@ | |||
# ChangeLog | |||
|
|||
## v2.0.0 (2025-04-28 |
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.
It is recommended to update the version to 1.1.0
. Additionally, one side of the parenthesis is missing.
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.
Fixed the version.
|
||
# Component: AHT20 | ||
I2C driver and definition of AHT20 humidity and temperature sensor. | ||
#Features |
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.
#Features | |
# Features |
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.
I've updated this locally, waiting for your decision on the other recommendation.
hi @YanKE01 Check copyright notices..................................................Passed Update versions in readme................................................Failed
Traceback (most recent call last): codespell................................................................Passed |
Bumped driver version from 1.0.0 to 1.1.0. Switched to internal i2c_bus component from esp-iot-solution, replacing legacy I2C code. Added new APIs to retrieve temperature and humidity. Introduced Kconfig options for CRC check and I2C clock frequency configuration. Updated README to reflect new APIs and configuration options. Changes to be committed: modified: CHANGELOG.md modified: CMakeLists.txt new file: Kconfig modified: README.md modified: aht20.c modified: idf_component.yml modified: include/aht20.h
Updated the test application to work with the new version of the AHT20 driver (v1.1.0). Modified test code to include the new APIs for reading sensor values. Changes to be committed: modified: test_apps/CMakeLists.txt modified: test_apps/main/CMakeLists.txt modified: test_apps/main/Kconfig.projbuild new file: test_apps/main/aht20_test_app.c new file: test_apps/main/idf_component.yml modified: test_apps/pytest_aht20.py
Added a demo application to illustrate usage of the updated AHT20 driver (v1.1.0). Demo includes usage of new sensor read APIs. Also serves as a reference for integrating the i2c_bus component from esp-iot-solution. Changes to be committed: new file: aht20_demo/CMakeLists.txt new file: aht20_demo/README.md new file: aht20_demo/main/CMakeLists.txt new file: aht20_demo/main/aht20_demo.c new file: aht20_demo/main/idf_component.yml
Hi @YanKE01 If you still find anything that needs to be fixed, let me know. Also, I haven't merged this with Sensor Hub, because..... 🤐 Thanks for pointing me out to use the i2c_bus component, I dislike it for my own reasons, but it was helpful in its own ways. |
Hi, @jeetrohan . Thank you very much for your contribution. The Additionally, the design principles of |
Hi @YanKE01, This will become a very long rant if I will go on explaining everything. Even without details : I'm not going to talk about features because, in my humble opinion, there are plenty of helpful features in current implementation. Additionally, no matter the amount of features, somebody can always come up with some niche but kind of essential feature. What I'm going to talk about is, its structure or the framework itself.
Where is this coming from?? What I can do at the moment for certain: Why the delay in some things? |
I've not checked the code... but... |
Hi @YanKE01 , And if there is any other thing to finalize this contribution, please let me know. |
You can see from the commit history of As for your question about why
|
@YanKE01,
This will ensure both compatibility with previous versions.. without adding another layer of locking mechanism on an existing one (provided it is same as the one in esp-idf=5.4). Correction: In 4. above, it may still affect the performance under certain circumstances, even if the tasks are not time critical... but, that will depend on how these were implemented. And as I'm mentioning once again, I've not checked the exact implementations, so I can't say for sure. |
Hi, @jeetrohan. I still recommend that you use |
@YanKE01 Please check the commit log from from last week's submission. I've already updated this driver to use i2c_bus and I've informed you regarding the same. |
@@ -1,5 +1,8 @@ | |||
# ChangeLog | |||
|
|||
## v1.1.1 (2025-05-02) | |||
* replace the i2c interface with i2c_bus |
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.
- Replace the i2c interface with
i2c_bus
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.
fixed.
@@ -1,8 +1,7 @@ | |||
# The following lines of boilerplate have to be in your project's CMakeLists | |||
# in this exact order for cmake to work correctly | |||
cmake_minimum_required(VERSION 3.5) | |||
cmake_minimum_required(VERSION 3.16) |
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.
If no new features of CMake are being used, I believe there's no need to make any changes.
cmake_minimum_required(VERSION 3.16) | |
cmake_minimum_required(VERSION 3.5) |
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.
fixed.
But,
I had replaced the original files with my local files rather than editing (version 3.16 was used).
Please check the compilation after this change with corresponding CMake version.
|
||
set(EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/unit-test-app/components" | ||
"../../aht20") | ||
set(COMPONENTS main) |
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.
set(COMPONENTS main) | |
set(EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/unit-test-app/components") |
Please do not remove unit-test-app/components, otherwise the following issues will occur:
➜ test_apps git:(pr-503) idf.py set-target esp32s3
Adding "set-target"'s dependency "fullclean" to list of commands with default set of options.
Executing action: fullclean
Build directory '/home/yanke/project/esp-iot-solution/components/sensors/humiture/aht20/test_apps/build' not found. Nothing to clean.
Executing action: set-target
Set Target to: esp32s3, new sdkconfig will be created.
Running cmake in directory /home/yanke/project/esp-iot-solution/components/sensors/humiture/aht20/test_apps/build
Executing "cmake -G Ninja -DPYTHON_DEPS_CHECKED=1 -DPYTHON=/home/yanke/.espressif/python_env/idf5.5_py3.11_env/bin/python -DESP_PLATFORM=1 -DIDF_TARGET=esp32s3 -DCCACHE_ENABLE=0 /home/yanke/project/esp-iot-solution/components/sensors/humiture/aht20/test_apps"...
-- Found Git: /usr/bin/git (found version "2.34.1")
-- Minimal build - OFF
-- The C compiler identification is GNU 14.2.0
-- The CXX compiler identification is GNU 14.2.0
-- The ASM compiler identification is GNU
-- Found assembler: /home/yanke/.espressif/tools/xtensa-esp-elf/esp-14.2.0_20241119/xtensa-esp-elf/bin/xtensa-esp32s3-elf-gcc
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /home/yanke/.espressif/tools/xtensa-esp-elf/esp-14.2.0_20241119/xtensa-esp-elf/bin/xtensa-esp32s3-elf-gcc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /home/yanke/.espressif/tools/xtensa-esp-elf/esp-14.2.0_20241119/xtensa-esp-elf/bin/xtensa-esp32s3-elf-g++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Building ESP-IDF components for target esp32s3
NOTICE: Dependencies lock doesn't exist, solving dependencies.
NOTICE: Using component placed at /home/yanke/project/esp-iot-solution/components/sensors/humiture/aht20 for dependency "aht20", specified in /home/yanke/project/esp-iot-solution/components/sensors/humiture/aht20/test_apps/main/idf_component.yml
......NOTICE: Updating lock file at /home/yanke/project/esp-iot-solution/components/sensors/humiture/aht20/test_apps/dependencies.lock
NOTICE: Processing 4 dependencies:
NOTICE: [1/4] aht20 (1.1.0) (/home/yanke/project/esp-iot-solution/components/sensors/humiture/aht20)
NOTICE: [2/4] espressif/cmake_utilities (0.5.3)
NOTICE: [3/4] i2c_bus (1.4.0) (/home/yanke/project/esp-iot-solution/components/i2c_bus)
NOTICE: [4/4] idf (5.5.0)
CMake Error at /home/yanke/esp/esp-idf/tools/cmake/build.cmake:328 (message):
Failed to resolve component 'test_utils' required by component 'main':
unknown name.
Call Stack (most recent call first):
/home/yanke/esp/esp-idf/tools/cmake/build.cmake:377 (__build_resolve_and_add_req)
/home/yanke/esp/esp-idf/tools/cmake/build.cmake:676 (__build_expand_requirements)
/home/yanke/esp/esp-idf/tools/cmake/project.cmake:736 (idf_build_process)
CMakeLists.txt:7 (project)
-- Configuring incomplete, errors occurred!
See also "/home/yanke/project/esp-iot-solution/components/sensors/humiture/aht20/test_apps/build/CMakeFiles/CMakeOutput.log".
HINT: The component 'test_utils' could not be found. This could be because: component name was misspelled, the component was not added to the build, the component has been moved to the IDF component manager, the component has been removed and refactored into some other component or the component may not be supported by the selected target.
Please look out for component in 'https://components.espressif.com' and add using 'idf.py add-dependency' command.
Refer to the migration guide for more details about moved components.
Refer to the build-system guide for more details about how components are found and included in the build.
cmake failed with exit code 1, output of the command is in the /home/yanke/project/esp-iot-solution/components/sensors/humiture/aht20/test_apps/build/log/idf_py_stderr_output_289434 and /home/yanke/project/esp-iot-solution/components/sensors/humiture/aht20/test_apps/build/log/idf_py_stdout_output_289434
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.
fixed.
@@ -1,32 +1,90 @@ | |||
[](https://components.espressif.com/components/espressif/aht20) | |||
# aht20 |
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.
In my opinion, no modifications are needed at this point.
# aht20 | |
[](https://components.espressif.com/components/espressif/aht20) | |
# Component: AHT20 |
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.
fixed.
Follow the example to learn how to initialize the driver and read the sensor data. | ||
|
||
All public APIs are documented in aht20.h. |
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.
I'm not sure what the indentation means 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.
fixed.
return ESP_OK; | ||
} | ||
|
||
esp_err_t aht20_read_humiture(aht20_handle_t aht20_handle) |
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.
I'm not quite sure what the purpose of this function is. It's uncommon to put data inside a handle. In other words, compared to aht20_read_humidity
, what makes this function necessary?
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.
@YanKE01
This... will be a long answer... and one without TLDR.
There are two questions here....
- Why provide aht20_read_humiture() to read at once both temperature and humidity when there are separate APIs aht20_read_humidity() and aht20_read_temperature().
- And even if implement it ... why the way it has been?
So the answer to 1. :
AHT20 datasheet indicate/directs that readings should be taken at the interval of minimum 2 seconds.
This means user should wait for at least 2 seconds in between calling aht20_read_humidity() and aht20_read_temperature(); as each of these function are equivalent of a single sensor data read.
However, it is somewhat inconvenient or at least not desired to have a delay between readings for associated parameters.. although unlikely that there will be much fluctuations in value, within 2 seconds. But still unnecessary when user wants to read both, because every read provides raw values for both.
If my memory serves correctly, some resources indicated that reading faster than 2 seconds may damage hardware, but I'm not sure how reliable this information is.
And answer to 2. :
I agree, its unconventional to put results in handle, at least in ESP ecosystem. But consider this just as a handy feature.. providing user with more convenient access to the data they are most likely to access with one thing that they will definitely need to access any call to sensor.
But why as a structure and not simply float variable? Again convenience to user in passing packed data.
Now what could be done.. :
- Completely remove aht20_read_humiture()
- Keep aht20_read_humiture(), but, instead of structure use simple float variables in handle.
- Keep aht20_read_humiture(), but return the structure instead of storing in handle.
- Keep the aht20_read_humiture() as it is.
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.
It's uncommon to put data inside a handle.
@YanKE01
There are 3 other reasons I can quote for this particular choice:
- Security (too nascent stage to discuss).
- Inter task communication.(self-explanatory)
- Memory safety(goes out with deinit()).
When I make alterations to the existing structures/conventional approaches its after considering from multiple aspects.
However, allow me to make it easier to choose ...
Whether you would like to uphold the traditional choices, or add new features.. as long as they are not breaking the existing system or conflict with any possible future updates?
If you think this conflicts with current or any possible future updates.. let's just drop it.
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.
@YanKE01 is my response sufficient enough to explain the purpose?
or should I remove this function altogether?
Although, I've come to understand your question better when I delved again in Sensor_Hub implementation. This would appear as redundant.
However, the implementation of aht20 drive needs to be tweaked a bit in order to display its functionality in that case.
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.
I'm not very certain myself. I feel like this is a feature I would hardly ever come across.
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.
@YanKE01 If you feel like the feature has no particular use I don't mind dropping it.. but.. please keep the following in consideration when making a decision.
even if nothing else..
AHT20 datasheet indicate/directs that readings should be taken at the interval of minimum 2 seconds.
This means user should wait for at least 2 seconds in between calling aht20_read_humidity() and aht20_read_temperature(); as each of these function are equivalent of a single sensor data read.
However, it is somewhat inconvenient or at least not desired to have a delay between readings for associated parameters.. although unlikely that there will be much fluctuations in value, within 2 seconds. But still unnecessary when user wants to read both, because every read provides raw values for both.
and....
If my memory serves correctly, some resources indicated that reading faster than 2 seconds may damage hardware, but I'm not sure how reliable this information is.
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.
I'm not very certain myself. I feel like this is a feature I would hardly ever come across.
@YanKE01 please also clarify if you're talking about ..
just this... aht20_read_humiture()
or
adding the results in handle or both?
return ESP_OK; | ||
} | ||
|
||
static esp_err_t aht_JH_Reset_REG(aht20_handle_t aht20_handle, uint8_t addr) |
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.
Please make sure the function naming follows a consistent format throughout the code.
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.
fixed.
@@ -2,13 +2,13 @@ menu "Example Configuration" | |||
|
|||
config I2C_MASTER_SCL | |||
int "SCL GPIO Num" | |||
default 40 | |||
default 22 |
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.
Since this is a Kconfig option, I think it's fine to leave it as is unless there's a strong reason to change it — users can always configure it to the IO they need.
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.
fixed.
I had just updated it with values I used on esp32.
Had replaced with local files during updated, rather than editing.
@@ -0,0 +1,7 @@ | |||
# The following five lines of boilerplate have to be in your project's |
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 usage of AHT20 is already clearly explained in the component's README. @leeebo , do you think it's still necessary to write an additional example?
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.
@YanKE01 and @leeebo ,
Sorry.. I didn't noticed the question was directed not at me, until I was about to comment..(edit: I mean post it)
But since.. I've..
consider this as my opinion or suggestion, I don't what it is, to both of you.
Of course, I will remove the example from my end, if that's the conclusion you two reach to.
Many, if not most, developers will agree with your sentiment; maybe I'm the odd one out.
Allow me to rephrase your question:
"There's a perfectly fine instruction manual so why the demo?"
I'll answer you as a typical layman user, in the most laymen language I can :
Note: Laymen in this context is a user who knows his way around C language, IDEs and has experience of working with micro-controllers but has zero interest in understanding the underlying framework used in esp32 ecosystem.
"I just want to use this sensor, to get some readings.. I don't want to bother to implement it myself.. and definitely not interested in how the readings are being collected by underlying framework... I just want to get the readings and use them for whatever insidious(humor, not serious) purposes I have.
I don't want to implement nothing (intentionally written instead of anything)."
In more simpler words.. Its for people used to Arduino, fire and forget.
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.
@leeebo I'm still waiting for your response. I will use that as guideline for the next two sensors I'll be contributing to this repository.(drivers already tested on hardware).
On branch update_aht20 Changes to be committed: modified: components/sensors/humiture/aht20/CHANGELOG.md modified: components/sensors/humiture/aht20/README.md modified: components/sensors/humiture/aht20/aht20.c modified: components/sensors/humiture/aht20/idf_component.yml modified: components/sensors/humiture/aht20/priv_include/aht20_reg.h modified: components/sensors/humiture/aht20/test_apps/CMakeLists.txt modified: components/sensors/humiture/aht20/test_apps/main/Kconfig.projbuild deleted: components/sensors/humiture/aht20/test_apps/main/aht20_test.c modified: components/sensors/humiture/aht20/test_apps/main/aht20_test_app.c modified: examples/sensors/aht20_demo/main/CMakeLists.txt
I noticed that in test_apps, the I2C bus handle is created via (1) "AHT20 Sensor" [aht20][sensor]
Enter test for running.
1
Running AHT20 Sensor...
Requesting I2C bus handle
I2C bus handle acquired
I (1640) AHT20: adding aht20 as device to bus
E (1640) i2c_bus: /home/yanke/project/esp-iot-solution/components/i2c_bus/i2c_bus_v2.c:185 (i2c_bus_device_create):i2c_bus has not inited
E (1650) AHT20: aht20_create(290): unable to create device
E (1650) i2c_bus: /home/yanke/project/esp-iot-solution/components/i2c_bus/i2c_bus_v2.c:214 (i2c_bus_device_delete):Null Device Handle
MALLOC_CAP_8BIT: Before 388860 bytes free, After 388756 bytes free (delta -104)
MALLOC_CAP_32BIT: Before 388860 bytes free, After 388756 bytes free (delta -104)
./main/aht20_test_app.c:123:AHT20 Sensor:PASS
Test ran in 58ms |
@YanKE01 or can I just add the Sensor Hub relevant code and update it as it is, without the unit test? |
What specific issues have you encountered? |
Rather than using sensor_hub, I decided to use the humiture functions. And the reason, I'm trying to drop this by simply adding the required Sensor Hub files is that.. And I've another request, please mark the conversations as resolved regarding queries which you raised and believe are resolved. |
I think you should add the dependency for version: "0.2.0"
description: I2C driver for SHT3X humiture sensor
url: https://github.com/espressif/esp-iot-solution/tree/master/components/sensors/humiture/sht3x
repository: https://github.com/espressif/esp-iot-solution.git
documentation: https://docs.espressif.com/projects/esp-iot-solution/en/latest/sensors/humiture.html
issues: https://github.com/espressif/esp-iot-solution/issues
dependencies:
i2c_bus:
public: true
override_path: "../../../i2c_bus"
sensor_hub:
public: true
override_path: "../../sensor_hub"
idf: '>=4.4'
cmake_utilities: "0.*"
|
@YanKE01 ah20 idf._component.yml:
I think the problem is here, aht20 CMakeLists.txt:
There are no proper instructions, what should be here: and if you will read the error: This is test app CMakelists.txt: & its idf_component.yml : |
Perhaps support for the sensor hub can be added in a separate PR next time, as this PR already includes too many changes. |
Thanks @YanKE01. |
Updated AHT20 driver to support Sensor Hub integration. Added a dedicated test application to verify functionality with Sensor Hub Humiture Sensor APIs. Included a new example demonstrating how to use AHT20 through the Sensor Hub interface. On branch update_aht20 Changes to be committed: modified: components/sensors/humiture/aht20/CMakeLists.txt modified: components/sensors/humiture/aht20/aht20.c modified: components/sensors/humiture/aht20/idf_component.yml modified: components/sensors/humiture/aht20/include/aht20.h renamed: components/sensors/humiture/aht20/test_apps/CMakeLists.txt -> components/sensors/humiture/aht20/test_apps/aht20_driver_test/CMakeLists.txt renamed: components/sensors/humiture/aht20/test_apps/main/CMakeLists.txt -> components/sensors/humiture/aht20/test_apps/aht20_driver_test/main/CMakeLists.txt renamed: components/sensors/humiture/aht20/test_apps/main/Kconfig.projbuild -> components/sensors/humiture/aht20/test_apps/aht20_driver_test/main/Kconfig.projbuild renamed: components/sensors/humiture/aht20/test_apps/main/aht20_test_app.c -> components/sensors/humiture/aht20/test_apps/aht20_driver_test/main/aht20_test_app.c renamed: components/sensors/humiture/aht20/test_apps/main/idf_component.yml -> components/sensors/humiture/aht20/test_apps/aht20_driver_test/main/idf_component.yml renamed: components/sensors/humiture/aht20/test_apps/pytest_aht20.py -> components/sensors/humiture/aht20/test_apps/aht20_driver_test/pytest_aht20.py renamed: components/sensors/humiture/aht20/test_apps/sdkconfig.defaults -> components/sensors/humiture/aht20/test_apps/aht20_driver_test/sdkconfig.defaults new file: components/sensors/humiture/aht20/test_apps/aht20_sensor_hub_humiture/CMakeLists.txt new file: components/sensors/humiture/aht20/test_apps/aht20_sensor_hub_humiture/main/CMakeLists.txt new file: components/sensors/humiture/aht20/test_apps/aht20_sensor_hub_humiture/main/Kconfig.projbuild new file: components/sensors/humiture/aht20/test_apps/aht20_sensor_hub_humiture/main/aht20_Sensor_Hub_Humiture.c new file: components/sensors/humiture/aht20/test_apps/aht20_sensor_hub_humiture/main/idf_component.yml new file: components/sensors/humiture/aht20/test_apps/aht20_sensor_hub_humiture/pytest_aht20.py new file: components/sensors/humiture/aht20/test_apps/aht20_sensor_hub_humiture/sdkconfig.defaults new file: examples/sensors/aht20_Sensor_Hub/CMakeLists.txt new file: examples/sensors/aht20_Sensor_Hub/README.md new file: examples/sensors/aht20_Sensor_Hub/main/CMakeLists.txt new file: examples/sensors/aht20_Sensor_Hub/main/Kconfig.projbuild new file: examples/sensors/aht20_Sensor_Hub/main/aht20_demo_sensor_hub.c new file: examples/sensors/aht20_Sensor_Hub/main/idf_component.yml modified: examples/sensors/aht20_demo/CMakeLists.txt modified: examples/sensors/aht20_demo/main/aht20_demo.c
Hi @YanKE01 , |
Hi @YanKE01, PS: and while you are at it.. could you ask leeebo to respond to your previous query too(regarding examples)? |
- Expanded documentation with additional details - Fixed a typo in `main.c` of the associated example - Updated `CHANGELOG.md` to reflect recent updates On branch update_aht20 Changes to be committed: modified: components/sensors/humiture/aht20/CHANGELOG.md modified: components/sensors/humiture/aht20/README.md deleted: components/sensors/humiture/aht20/priv_include/aht20_reg.h modified: examples/sensors/aht20_Sensor_Hub/README.md modified: examples/sensors/aht20_Sensor_Hub/main/aht20_demo_sensor_hub.c
Hi @YanKE01 and @leeebo I think we have spent more than a month on this simple driver and now I would be happy to see it integrated in the repository. Let me know if there are any remaining issues. I've already provided a explanation to all the issues raised earlier in this PR, in context of standalone use of driver. So either I can drop all the particular APIs and refactors I've made to this driver. PS: |
… v1.1.0 - Replaced legacy I2C operations with esp-iot-solution's i2c_bus component - Added Kconfig options for CRC check and I2C clock speed configuration - Updated driver version from 1.0.0 to 1.1.0 - Updated documentation and test application accordingly Changes to be committed:
I've refactored the code to original, i.e. now this PR only changes the I2C interface and corresponding parts in original driver. Its easier to solve problems when they are simple, but its more easier to ignore them when they're simple (context : the updates originally suggested in this PR). But I'm assuming there are better solutions, and this was one was not implemented to full extent, primarily to not cause any conflict with Sensor Hub as it is now. |
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.
Hi, @jeetrohan .Thank you very much for your contribution and for testing the sensor_hub
. I have no additional comments after completing this review.
components/sensors/humiture/aht20/test_apps/aht20_driver_test/CMakeLists.txt
Outdated
Show resolved
Hide resolved
…sor handle - Removed `CONFIG_AHT20_I2C_CLK_SPEED` Kconfig option - Replaced with i2c_bus_get_current_clk_speed() API - Ensures better consistency with bus-level configuration - Refactored AHT20 handle to a void pointer to encapsulate internal structure - Moved internal handle definition to implementation file Changes to be committed: modified: Kconfig modified: README.md modified: aht20.c modified: include/aht20.h modified: test_apps/aht20_driver_test/CMakeLists.txt modified: test_apps/aht20_driver_test/main/aht20_test_app.c deleted: test_apps/aht20_driver_test/main/idf_component.yml
original files reverted to previous state and lost the history too.
@YanKE01 is it now acceptable for the merge? |
We still need to wait for reviews from other relevant personnel. In the meantime, I think it would be good to squash the commit messages — there are too many at the moment. |
Edit: @YanKE01 |
Description
Updated the AHT20 driver.
Supports new thread safe I2C APIs introduced in idf=5.4.
Related
Testing
Tested using AHT20 latest revision with esp32 and exp32-s3 devkits.
Checklist
Before submitting a Pull Request, please ensure the following: