mirror of
https://github.com/esphome/esphome.git
synced 2024-11-30 02:34:12 +01:00
ccs811: Skip reading data if it is not available (#2404)
On bootup the ccs811 reports that no data is available. No error flag is set in that case. The current implementation ignores this, reads and publishes the invalid data, which is 0xFDFD for both tvoc and co2 in my case. This commit fixes this and does not read and publish invalid data.
This commit is contained in:
parent
45940b0514
commit
b2d516c70a
1 changed files with 4 additions and 1 deletions
|
@ -86,8 +86,11 @@ void CCS811Component::setup() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void CCS811Component::update() {
|
void CCS811Component::update() {
|
||||||
if (!this->status_has_data_())
|
if (!this->status_has_data_()) {
|
||||||
|
ESP_LOGD(TAG, "Status indicates no data ready!");
|
||||||
this->status_set_warning();
|
this->status_set_warning();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// page 12 - alg result data
|
// page 12 - alg result data
|
||||||
auto alg_data = this->read_bytes<4>(0x02);
|
auto alg_data = this->read_bytes<4>(0x02);
|
||||||
|
|
Loading…
Reference in a new issue