mirror of
https://github.com/esphome/esphome.git
synced 2024-11-27 17:27:59 +01:00
fix error handling
This commit is contained in:
parent
32ce8e9bc4
commit
69df9c9ea4
1 changed files with 2 additions and 2 deletions
|
@ -10,7 +10,7 @@ static const char *const TAG = "mcp3221";
|
|||
void MCP3221Sensor::setup() {
|
||||
ESP_LOGCONFIG(TAG, "Probing MCP3221...");
|
||||
|
||||
if (!this->write(nullptr, 0)) {
|
||||
if (this->write(nullptr, 0) != i2c::ERROR_OK) {
|
||||
this->mark_failed();
|
||||
return;
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ float MCP3221Sensor::get_setup_priority() const { return setup_priority::DATA; }
|
|||
|
||||
float MCP3221Sensor::sample() {
|
||||
uint8_t data[2];
|
||||
if (!this->read(data, 2)) {
|
||||
if (this->read(data, 2) != i2c::ERROR_OK) {
|
||||
ESP_LOGW(TAG, "Failed to read data from MCP3221");
|
||||
this->status_set_warning();
|
||||
return NAN;
|
||||
|
|
Loading…
Reference in a new issue