Skip to content

Commit 4f076d7

Browse files
committed
fix(aht20): fixed minor changes
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
1 parent 3e4c618 commit 4f076d7

File tree

10 files changed

+27
-130
lines changed

10 files changed

+27
-130
lines changed

components/sensors/humiture/aht20/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# ChangeLog
22

33
## v1.1.1 (2025-05-02)
4-
* replace the i2c interface with i2c_bus
4+
* Replace the i2c interface with i2c_bus
55

66
## v1.0.0 (2024-08-09)
77

components/sensors/humiture/aht20/README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# aht20
1+
# Component: AHT20
22
I2C driver for Aosong AHT20 humidity and temperature sensor using esp-idf.
33
Tested with AHT20 using ESP32 and ESP32-S3 devkits.
44

@@ -47,23 +47,23 @@ Tested with AHT20 using ESP32 and ESP32-S3 devkits.
4747

4848
This driver includes a demo example project.
4949

50-
Follow the example to learn how to initialize the driver and read the sensor data.
50+
Follow the example to learn how to initialize the driver and read the sensor data.
5151

52-
All public APIs are documented in aht20.h.
52+
All public APIs are documented in aht20.h.
5353

5454

5555

56-
However, following are the general guiedlines.
56+
Following are the general guidelines.
5757
```c
5858
//create a AHT20 device object and receive a device handle for it
5959
// my_i2c_bus_handle is a preintialized i2c_bus_handle_t object
60-
aht20_handle_t aht20_handle = aht20_create( my_i2c_bus_handle, AHT20_ADDRESS_LOW ); //addresses are in aht.h
60+
aht20_handle_t aht20_handle = aht20_create( my_i2c_bus_handle, AHT20_ADDRESS_LOW ); //addresses are in aht20.h
6161

6262
//use the previously created AHT20 device handle for initializing the associated device
6363
aht20_init(aht20_handle);
6464

6565
//read both humidity and temperature at once from device, using AHT20 device handle
66-
aht20_read_humiture(aht20_handle); //Other public APIs are documented in AHT20.h.
66+
aht20_read_humiture(aht20_handle); //Other public APIs are documented in aht20.h.
6767

6868
//access the results stored in AHT20 device object, using the AHT20 device handle
6969
//other apis require user to explicitly pass variable address to hold data
@@ -77,7 +77,7 @@ However, following are the general guiedlines.
7777
7878
7979
# How to Configure CRC and I2C clock speed
80-
Additionally, select in menuconfig under Component Config → AHT20,; to use CRC(default is not used)
80+
Additionally, select in menuconfig under Component Config → AHT20; to use CRC(default is not used)
8181
or change the clock speed of device (default is 100KHz).
8282
8383
Note : It is recommended to use clock speeds in upper ranges of 100kHz to 200kHz.

components/sensors/humiture/aht20/aht20.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ static esp_err_t aht20_Start_Init(aht20_handle_t aht20_handle);
5959
* @param[in] addr AHT20 internal register, undocumented in datasheet
6060
*
6161
*/
62-
static esp_err_t aht_JH_Reset_REG(aht20_handle_t aht20_handle, uint8_t addr);
62+
static esp_err_t aht20_JH_Reset_REG(aht20_handle_t aht20_handle, uint8_t addr);
6363

6464
/**
6565
* @brief check crc validity of response received
@@ -217,7 +217,7 @@ esp_err_t aht20_busy_status(aht20_handle_t aht20_handle, bool *busy)
217217
return ESP_OK;
218218
}
219219

220-
static esp_err_t aht_JH_Reset_REG(aht20_handle_t aht20_handle, uint8_t addr)
220+
static esp_err_t aht20_JH_Reset_REG(aht20_handle_t aht20_handle, uint8_t addr)
221221
{
222222

223223
uint8_t reset_cmd[] = {addr, 0x00, 0x00}, read_bytes[3];
@@ -241,9 +241,9 @@ static esp_err_t aht_JH_Reset_REG(aht20_handle_t aht20_handle, uint8_t addr)
241241

242242
static esp_err_t aht20_Start_Init(aht20_handle_t aht20_handle)
243243
{
244-
ESP_RETURN_ON_ERROR(aht_JH_Reset_REG(aht20_handle, 0x1b), "", "");
245-
ESP_RETURN_ON_ERROR(aht_JH_Reset_REG(aht20_handle, 0x1c), "", "");
246-
ESP_RETURN_ON_ERROR(aht_JH_Reset_REG(aht20_handle, 0x1e), "", "");
244+
ESP_RETURN_ON_ERROR(aht20_JH_Reset_REG(aht20_handle, 0x1b), "", "");
245+
ESP_RETURN_ON_ERROR(aht20_JH_Reset_REG(aht20_handle, 0x1c), "", "");
246+
ESP_RETURN_ON_ERROR(aht20_JH_Reset_REG(aht20_handle, 0x1e), "", "");
247247

248248
return ESP_OK;
249249
}

components/sensors/humiture/aht20/idf_component.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ dependencies:
2020

2121
idf: ">=4.0"
2222

23+
examples:
24+
- path: ../../../examples/sensors/aht20_demo
25+
2326
targets:
2427
- esp32
2528
- esp32c2
Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -14,11 +14,3 @@
1414
#define SUPPLY_VOLTAGE_MAX (5.5f) /**< chip max supply voltage */
1515
#define TEMPERATURE_MIN (-40.0f) /**< chip min operating temperature */
1616
#define TEMPERATURE_MAX (125.0f) /**< chip max operating temperature */
17-
18-
#define AHT20_START_MEASURMENT_CMD 0xAC /* start measurement command */
19-
20-
#define AT581X_STATUS_CMP_INT (2) /* 1 --Out threshold range; 0 --In threshold range */
21-
#define AT581X_STATUS_Calibration_Enable (3) /* 1 --Calibration enable; 0 --Calibration disable */
22-
#define AT581X_STATUS_CRC_FLAG (4) /* 1 --CRC ok; 0 --CRC failed */
23-
#define AT581X_STATUS_MODE_STATUS (5) /* 00 -NOR mode; 01 -CYC mode; 1x --CMD mode */
24-
#define AT581X_STATUS_BUSY_INDICATION (7) /* 1 --Equipment is busy; 0 --Equipment is idle */
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# The following lines of boilerplate have to be in your project's CMakeLists
22
# in this exact order for cmake to work correctly
3-
cmake_minimum_required(VERSION 3.16)
3+
cmake_minimum_required(VERSION 3.5)
44

55
set(COMPONENTS main)
6+
set(EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/unit-test-app/components")
7+
68
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
79
project(aht20_test)

components/sensors/humiture/aht20/test_apps/main/Kconfig.projbuild

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ menu "Example Configuration"
22

33
config I2C_MASTER_SCL
44
int "SCL GPIO Num"
5-
default 22
5+
default 40
66
help
77
GPIO number for I2C Master clock line.
88

99
config I2C_MASTER_SDA
1010
int "SDA GPIO Num"
11-
default 21
11+
default 41
1212
help
1313
GPIO number for I2C Master data line.
1414

components/sensors/humiture/aht20/test_apps/main/aht20_test.c

Lines changed: 0 additions & 104 deletions
This file was deleted.

components/sensors/humiture/aht20/test_apps/main/aht20_test_app.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ void tearDown(void)
5555
{
5656
after_free_8bit = heap_caps_get_free_size(MALLOC_CAP_8BIT);
5757
after_free_32bit = heap_caps_get_free_size(MALLOC_CAP_32BIT);
58+
check_leak(before_free_8bit, after_free_8bit, "8BIT");
59+
check_leak(before_free_32bit, after_free_32bit, "32BIT");
5860
}
5961

6062
/************************** Memory Leak Checks Completed********************/
@@ -97,6 +99,7 @@ esp_err_t aht20_init_test()
9799
void aht20_deinit_test(void)
98100
{
99101
aht20_remove(&aht20_handle);
102+
i2c_del_master_bus(my_i2c_bus_handle);
100103
}
101104
/*******************************AHT20 Device Deinitializtion Over****************************/
102105

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
idf_component_register(SRCS "aht20_demo.c"
2-
INCLUDE_DIRS ".")
2+
INCLUDE_DIRS "."
3+
REQUIRES "aht20")

0 commit comments

Comments
 (0)