mirror of
https://github.com/esphome/esphome.git
synced 2024-11-26 12:27:13 +01:00
AHT10: Fix bug (#6409)
This commit is contained in:
parent
2997964b72
commit
e87727aed3
@ -40,19 +40,18 @@ void AHT10Component::setup() {
|
|||||||
}
|
}
|
||||||
delay(AHT10_SOFTRESET_DELAY);
|
delay(AHT10_SOFTRESET_DELAY);
|
||||||
|
|
||||||
const uint8_t *init_cmd;
|
i2c::ErrorCode error_code = i2c::ERROR_INVALID_ARGUMENT;
|
||||||
switch (this->variant_) {
|
switch (this->variant_) {
|
||||||
case AHT10Variant::AHT20:
|
case AHT10Variant::AHT20:
|
||||||
init_cmd = AHT20_INITIALIZE_CMD;
|
|
||||||
ESP_LOGCONFIG(TAG, "Setting up AHT20");
|
ESP_LOGCONFIG(TAG, "Setting up AHT20");
|
||||||
|
error_code = this->write(AHT20_INITIALIZE_CMD, sizeof(AHT20_INITIALIZE_CMD));
|
||||||
break;
|
break;
|
||||||
case AHT10Variant::AHT10:
|
case AHT10Variant::AHT10:
|
||||||
default:
|
|
||||||
init_cmd = AHT10_INITIALIZE_CMD;
|
|
||||||
ESP_LOGCONFIG(TAG, "Setting up AHT10");
|
ESP_LOGCONFIG(TAG, "Setting up AHT10");
|
||||||
|
error_code = this->write(AHT10_INITIALIZE_CMD, sizeof(AHT10_INITIALIZE_CMD));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
if (error_code != i2c::ERROR_OK) {
|
||||||
if (this->write(init_cmd, sizeof(init_cmd)) != i2c::ERROR_OK) {
|
|
||||||
ESP_LOGE(TAG, "Communication with AHT10 failed!");
|
ESP_LOGE(TAG, "Communication with AHT10 failed!");
|
||||||
this->mark_failed();
|
this->mark_failed();
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user