hx711: Check for DOUT going high after a reading (#7214)

This commit is contained in:
David Woodhouse 2024-08-08 03:29:49 +01:00 committed by GitHub
parent 24b6c1d3eb
commit 7fd65987d3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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;
@ -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;
}