Skip to content

Commit

Permalink
hx711: Check for DOUT going high after a reading (esphome#7214)
Browse files Browse the repository at this point in the history
  • Loading branch information
dwmw2 authored Aug 8, 2024
1 parent 24b6c1d commit 7fd6598
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion esphome/components/hx711/hx711.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ bool HX711Sensor::read_sensor_(uint32_t *result) {
return false;
}

this->status_clear_warning();
uint32_t data = 0;
bool final_dout;

{
InterruptLock lock;
Expand All @@ -59,8 +59,17 @@ bool HX711Sensor::read_sensor_(uint32_t *result) {
this->sck_pin_->digital_write(false);
delayMicroseconds(1);
}
final_dout = this->dout_pin_->digital_read();
}

if (!final_dout) {
ESP_LOGW(TAG, "HX711 DOUT pin not high after reading (data 0x%" PRIx32 ")!", data);
this->status_set_warning();
return false;
}

this->status_clear_warning();

if (data & 0x800000ULL) {
data |= 0xFF000000ULL;
}
Expand Down

0 comments on commit 7fd6598

Please sign in to comment.