39 void setup()
override;
44#ifdef MICS_5524_GAS_COUNT
96#ifdef MICS_5524_GAS_COUNT
This class simplifies creating components that periodically check a state.
Minimal static vector - saves memory by avoiding std::vector overhead.
The MiCS-5524 breakout: one analog output, converted for every configured gas against the clean-air r...
void begin_calibration_()
uint32_t calibration_samples_
0 when calibration is disabled.
void set_voltage_multiplier(float multiplier)
MiCS5524Component(voltage_sampler::VoltageSampler *source)
source must outlive this component, which code generation guarantees.
bool has_reference_() const
uint32_t calibration_count_
void register_gas_sensor(MiCS5524GasSensor *gas)
uint32_t sample_interval_
Spacing of the clean-air calibration samples (ms); the ~16 ms loop tick is the floor.
static constexpr uint32_t CALIBRATION_START_ID
void finish_calibration_()
uint32_t calibration_delay_
float reference_
Clean-air reference x_air in volts, 0 while there is none.
void publish_ratio_(float ratio)
StaticVector< MiCS5524GasSensor *, MICS_5524_GAS_COUNT > gases_
void set_warmup_time(uint32_t warmup)
float sample_voltage_()
Averaged, scaled output voltage (V); the conversions run back to back.
float voltage_multiplier_
void schedule_calibration_retry_()
void set_calibration(uint32_t delay, uint32_t samples, uint32_t sample_interval)
Calibrate at boot: start after delay ms, average samples readings sample_interval ms apart.
float read_air_value_()
x = vcc - V_AO, or NAN (and a status warning) when the voltage is unusable.
void dump_config() override
voltage_sampler::VoltageSampler * source_
uint32_t calibration_last_sample_
void set_samples(uint8_t samples)
static constexpr uint32_t CALIBRATION_RETRY_MIN_MS
Floor of the delay between two calibration attempts (ms).
uint32_t calibration_attempts_
void set_air_reference(float air_reference)
void process_calibration_()
float calibration_min_
Smallest and largest clean-air sample of the run, see calibration_is_stable().
One gas of a MiCS-5524: converts the measured ratio with the vendor curve of that gas.
float get_max_ppm() const
micsmath::VendorCurve curve_
void publish_ratio(float ratio)
Publish the concentration for ratio; NAN publishes unknown.
MiCS5524GasSensor(float threshold, float gain, float min_ppm, float max_ppm)
The vendor constants from coefficients.py.
float get_min_ppm() const
Base-class for all sensors.
Abstract interface for components to request voltage (usually ADC readings)
void HOT delay(uint32_t ms)
Per-gas constants of the vendor model.
float max_ppm
upper end of the measuring range
float min_ppm
the vendor reports 0 ppm below this