This commit is contained in:
2024-07-05 09:10:53 +03:00
parent cebee7859e
commit dd255e6a29
6 changed files with 39 additions and 12 deletions

View File

@ -76,6 +76,8 @@ void zh_load_config(sensor_config_t *sensor_config)
sensor_config->hardware_config.sensor_type = HAST_DS18B20;
#elif CONFIG_SENSOR_TYPE_DHT
sensor_config->hardware_config.sensor_type = HAST_DHT;
#elif CONFIG_SENSOR_TYPE_AHT
sensor_config->hardware_config.sensor_type = HAST_AHT;
#elif CONFIG_SENSOR_TYPE_BH1750
sensor_config->hardware_config.sensor_type = HAST_BH1750;
#else
@ -254,7 +256,17 @@ void zh_sensor_init(sensor_config_t *sensor_config)
break;
case HAST_BME680: // For future development.
break;
case HAST_AHT: // For future development.
case HAST_AHT:;
zh_aht_init_config_t aht_init_config = ZH_AHT_INIT_CONFIG_DEFAULT();
#ifdef CONFIG_IDF_TARGET_ESP8266
aht_init_config.i2c_port = I2C_PORT;
#else
aht_init_config.i2c_handle = sensor_config->i2c_bus_handle;
#endif
if (zh_aht_init(&aht_init_config) != ESP_OK)
{
goto ZH_SENSOR_ERROR;
}
break;
case HAST_SHT: // For future development.
break;
@ -371,7 +383,7 @@ uint8_t zh_send_sensor_config_message(const sensor_config_t *sensor_config)
++messages_quantity;
break;
case HAST_DHT:
case HAST_AHT: // For future development.
case HAST_AHT:
case HAST_SHT: // For future development.
case HAST_HTU21D: // For future development.
case HAST_HDC1080: // For future development.
@ -470,7 +482,14 @@ void zh_send_sensor_status_message_task(void *pvParameter)
break;
case HAST_BME680: // For future development.
break;
case HAST_AHT: // For future development.
case HAST_AHT:
err = zh_aht_read(&humidity, &temperature);
if (err == ESP_OK)
{
data.payload_data.status_message.sensor_status_message.humidity = humidity;
data.payload_data.status_message.sensor_status_message.temperature = temperature;
data.payload_data.status_message.sensor_status_message.voltage = 3.3; // For future development.
}
break;
case HAST_SHT: // For future development.
break;