mirror of
https://github.com/esphome/esphome.git
synced 2024-12-26 15:34:53 +01:00
fix error handling
This commit is contained in:
parent
69df9c9ea4
commit
86b0afd6b2
1 changed files with 2 additions and 1 deletions
|
@ -11,7 +11,7 @@ void MCP3221Sensor::setup() {
|
||||||
ESP_LOGCONFIG(TAG, "Probing MCP3221...");
|
ESP_LOGCONFIG(TAG, "Probing MCP3221...");
|
||||||
|
|
||||||
if (this->write(nullptr, 0) != i2c::ERROR_OK) {
|
if (this->write(nullptr, 0) != i2c::ERROR_OK) {
|
||||||
this->mark_failed();
|
this->status_set_warning();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@ float MCP3221Sensor::sample() {
|
||||||
this->status_set_warning();
|
this->status_set_warning();
|
||||||
return NAN;
|
return NAN;
|
||||||
}
|
}
|
||||||
|
this->status_clear_warning();
|
||||||
|
|
||||||
uint16_t value = encode_uint16(data[0], data[1]);
|
uint16_t value = encode_uint16(data[0], data[1]);
|
||||||
float voltage = value * this->reference_voltage_ / 4096.0f;
|
float voltage = value * this->reference_voltage_ / 4096.0f;
|
||||||
|
|
Loading…
Reference in a new issue