ESPHome 2026.11.0b6
Loading...
Searching...
No Matches
ccs811.h
Go to the documentation of this file.
1#pragma once
2
8
9namespace esphome::ccs811 {
10
11class CCS811Component final : public PollingComponent, public i2c::I2CDevice {
12 SUB_SENSOR(co2)
13 SUB_SENSOR(tvoc)
14 SUB_TEXT_SENSOR(version)
15 // Input sensors for humidity and temperature compensation
16 SUB_SENSOR(humidity)
17 SUB_SENSOR(temperature)
18
19 public:
20 void set_baseline(uint16_t baseline) { baseline_ = baseline; }
21
23 void setup() override;
25 void update() override;
26
27 void dump_config() override;
28
29 protected:
30 optional<uint8_t> read_status_() { return this->read_byte(0x00); }
31 bool status_has_error_() { return this->read_status_().value_or(1) & 1; }
32 bool status_app_is_valid_() { return this->read_status_().value_or(0) & (1 << 4); }
33 bool status_has_data_() { return this->read_status_().value_or(0) & (1 << 3); }
34 void send_env_data_();
35
36 optional<uint16_t> baseline_{};
37};
38
39} // namespace esphome::ccs811
This class simplifies creating components that periodically check a state.
Definition component.h:532
optional< uint16_t > baseline_
Definition ccs811.h:36
optional< uint8_t > read_status_()
Definition ccs811.h:30
This Class provides the methods to read/write bytes from/to an i2c device.
Definition i2c.h:144
bool read_byte(uint8_t a_register, uint8_t *data)
Definition i2c.h:272
uint16_t temperature
Definition sun_gtil2.cpp:12