feat!: added unique sensor handle
This commit is contained in:
1 parent
89ad22346c
commit
5269a4bade
4 files changed
+61
-36
No files matched your search
@@ -8,6 +8,15 @@
|
||||
|
||||
1. Support of AHT10/AHT15/AHT20/AHT21/AHT25/AHT30.
|
||||
|
||||
## Attention
|
||||
|
||||
For correct operation, please enable the following settings in the menuconfig:
|
||||
|
||||
```text
|
||||
I2C_ISR_IRAM_SAFE
|
||||
I2C_MASTER_ISR_HANDLER_IN_IRAM
|
||||
```
|
||||
|
||||
## Using
|
||||
|
||||
In an existing project, run the following command to install the component:
|
||||
@@ -32,6 +41,8 @@ Reading the sensor:
|
||||
|
||||
#define I2C_PORT (I2C_NUM_MAX - 1)
|
||||
|
||||
zh_aht_handle_t aht_handle = {0};
|
||||
|
||||
void app_main(void)
|
||||
{
|
||||
esp_log_level_set("zh_aht", ESP_LOG_ERROR);
|
||||
@@ -43,16 +54,16 @@ void app_main(void)
|
||||
.glitch_ignore_cnt = 7,
|
||||
.flags.enable_internal_pullup = true,
|
||||
};
|
||||
i2c_master_bus_handle_t i2c_bus_handle;
|
||||
i2c_master_bus_handle_t i2c_bus_handle = NULL;
|
||||
i2c_new_master_bus(&i2c_bus_config, &i2c_bus_handle);
|
||||
zh_aht_init_config_t aht_init_config = ZH_AHT_INIT_CONFIG_DEFAULT();
|
||||
aht_init_config.i2c_handle = i2c_bus_handle;
|
||||
zh_aht_init(&aht_init_config);
|
||||
zh_aht_init_config_t config = ZH_AHT_INIT_CONFIG_DEFAULT();
|
||||
config.i2c_handle = i2c_bus_handle;
|
||||
zh_aht_init(&config, &aht_handle);
|
||||
float humidity = 0.0;
|
||||
float temperature = 0.0;
|
||||
for (;;)
|
||||
{
|
||||
zh_aht_read(&humidity, &temperature);
|
||||
zh_aht_read(&aht_handle, &humidity, &temperature);
|
||||
printf("Humidity %0.2f\n", humidity);
|
||||
printf("Temperature %0.2f\n", temperature);
|
||||
vTaskDelay(5000 / portTICK_PERIOD_MS);
|
||||
|
||||
Reference in new issue
Block a user