11 #include <VOCGasIndexAlgorithm.h> 12 #include <NOxGasIndexAlgorithm.h> 34 static const uint8_t SGP40_FEATURESET = 0x0020;
35 static const uint8_t SGP41_FEATURESET = 0x0040;
37 static const uint16_t SGP4X_CMD_GET_SERIAL_ID = 0x3682;
38 static const uint16_t SGP4X_CMD_GET_FEATURESET = 0x202f;
39 static const uint16_t SGP4X_CMD_SELF_TEST = 0x280e;
40 static const uint16_t SGP40_CMD_MEASURE_RAW = 0x260F;
41 static const uint16_t SGP41_CMD_MEASURE_RAW = 0x2619;
42 static const uint16_t SGP41_CMD_NOX_CONDITIONING = 0x2612;
43 static const uint8_t SGP41_SUBCMD_NOX_CONDITIONING = 0x12;
48 static const uint16_t SPG40_SELFTEST_TIME = 250;
49 static const uint16_t SPG41_SELFTEST_TIME = 320;
50 static const uint16_t SGP40_MEASURE_TIME = 30;
51 static const uint16_t SGP41_MEASURE_TIME = 55;
67 } error_code_{UNKNOWN};
74 void setup()
override;
75 void update()
override;
76 void update_gas_indices();
77 void dump_config()
override;
83 uint16_t learning_time_gain_hours, uint16_t gating_max_duration_minutes,
84 uint16_t std_initial, uint16_t gain_factor) {
85 voc_tuning_params_.value().index_offset = index_offset;
86 voc_tuning_params_.value().learning_time_offset_hours = learning_time_offset_hours;
87 voc_tuning_params_.value().learning_time_gain_hours = learning_time_gain_hours;
88 voc_tuning_params_.value().gating_max_duration_minutes = gating_max_duration_minutes;
89 voc_tuning_params_.value().std_initial = std_initial;
90 voc_tuning_params_.value().gain_factor = gain_factor;
93 uint16_t learning_time_gain_hours, uint16_t gating_max_duration_minutes,
94 uint16_t gain_factor) {
95 nox_tuning_params_.value().index_offset = index_offset;
96 nox_tuning_params_.value().learning_time_offset_hours = learning_time_offset_hours;
97 nox_tuning_params_.value().learning_time_gain_hours = learning_time_gain_hours;
98 nox_tuning_params_.value().gating_max_duration_minutes = gating_max_duration_minutes;
99 nox_tuning_params_.value().std_initial = 50;
100 nox_tuning_params_.value().gain_factor = gain_factor;
109 int16_t sensirion_init_sensors_();
111 bool measure_gas_indices_(int32_t &voc, int32_t &nox);
112 bool measure_raw_(uint16_t &voc_raw, uint16_t &nox_raw);
126 int32_t voc_index_ = 0;
129 int32_t nox_index_ = 0;
134 uint8_t samples_read_ = 0;
135 uint8_t samples_to_stabilize_ =
static_cast<int8_t
>(GasIndexAlgorithm_INITIAL_BLACKOUT) * 2;
const float DATA
For components that import data from directly connected sensors like DHT.
void set_nox_algorithm_tuning(uint16_t index_offset, uint16_t learning_time_offset_hours, uint16_t learning_time_gain_hours, uint16_t gating_max_duration_minutes, uint16_t gain_factor)
void set_humidity_sensor(sensor::Sensor *humidity)
const float MAXIMUM_STORAGE_DIFF
This class implements support for the Sensirion sgp4x i2c GAS (VOC) sensors.
const uint32_t SHORTEST_BASELINE_STORE_INTERVAL
VOCGasIndexAlgorithm voc_algorithm_
optional< GasTuning > nox_tuning_params_
ESPPreferenceObject pref_
This class simplifies creating components that periodically check a state.
struct esphome::sgp4x::SGP4xBaselines PACKED
optional< GasTuning > voc_tuning_params_
float get_setup_priority() const override
uint16_t gating_max_duration_minutes
uint16_t learning_time_offset_hours
uint32_t seconds_since_last_store_
void set_store_baseline(bool store_baseline)
SGP4xBaselines voc_baselines_storage_
void set_nox_sensor(sensor::Sensor *nox_sensor)
NOxGasIndexAlgorithm nox_algorithm_
void set_voc_sensor(sensor::Sensor *voc_sensor)
Implementation of a i2c functions for Sensirion sensors Sensirion data requires crc checking...
void set_voc_algorithm_tuning(uint16_t index_offset, uint16_t learning_time_offset_hours, uint16_t learning_time_gain_hours, uint16_t gating_max_duration_minutes, uint16_t std_initial, uint16_t gain_factor)
void set_temperature_sensor(sensor::Sensor *temperature)
uint16_t learning_time_gain_hours
Implementation of SPI Controller mode.
Base-class for all sensors.