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:
Christian Taedcke 2021-09-27 21:53:05 +02:00 committed by GitHub
parent 45940b0514
commit b2d516c70a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions

View File

@ -86,8 +86,11 @@ void CCS811Component::setup() {
}
}
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();
return;
}
// page 12 - alg result data
auto alg_data = this->read_bytes<4>(0x02);