|
ESPHome 2026.11.0b6
|
Data Structures | |
| struct | VendorCurve |
| Per-gas constants of the vendor model. More... | |
Enumerations | |
| enum | ConversionModel : uint8_t { CONVERSION_MODEL_DFROBOT = 0 , CONVERSION_MODEL_DATASHEET = 1 } |
| Generated through CONVERSION_MODELS in init.py. More... | |
Functions | |
| float | air_value_from_voltage (float voltage, float vcc) |
| x = VCC - V_ao: 0 at VCC (a saturated sensor, never clean air). | |
| float | ratio_from_air_value (float x, float x_air) |
| ratio = x / x_air (NaN when either value is unusable). | |
| float | ppm_from_vendor_curve (float ratio, const VendorCurve &curve) |
| ratio -> ppm as DFRobot_MICS getGasData(): 0 above the threshold or below the vendor range, the top of the range at ratio 0 (a saturated sensor), NaN stays NaN. | |
| float | datasheet_dead_input_voltage (float vcc) |
| Smallest V_ao the datasheet model reads: the output of RS = MAX_RS_OVER_RL * RL. | |
| float | rs_from_voltage (float voltage, float vcc, float rl) |
| RS = (VCC * RL) / V - RL in kOhm: 0 at VCC (a saturated sensor). | |
| float | ratio_from_rs (float rs, float r0) |
| ratio = RS / R0 (NaN when either value is unusable); 0 is the saturated end. | |
| float | ppm_from_power_law (float a, float b, float ratio) |
| ppm = a * ratio^b; NaN for a ratio or coefficient that cannot produce a reading. | |
| float | clamp_ppm (float ppm, float min_ppm, float max_ppm) |
| Clamp to the configured range: below min_ppm counts as not detected and reads 0, 0 itself never changes, and a reading past a finite max_ppm (infinity included) is max_ppm. | |
| bool | calibration_is_stable (float min_value, float max_value, float mean) |
| True when the clean-air samples spread at most MAX_CALIBRATION_SPREAD of their mean. | |
Variables | |
| constexpr float | VENDOR_DEAD_INPUT_FRACTION = 0.05f |
| Share of VCC at or below which the vendor model reads the output as disconnected: clean air sits a volt or two below VCC, so a reading near 0 V is a wiring fault, not gas-free air. | |
| constexpr float | MAX_RS_OVER_RL = 200.0f |
| Largest RS the datasheet model reads, as a multiple of RL. | |
| constexpr float | MAX_CALIBRATION_SPREAD = 0.25f |
| Largest relative spread (max - min) / mean a clean-air calibration accepts. | |
| enum esphome::mics_5524::micsmath::ConversionModel : uint8_t |
Generated through CONVERSION_MODELS in init.py.
| Enumerator | |
|---|---|
| CONVERSION_MODEL_DFROBOT | |
| CONVERSION_MODEL_DATASHEET | |
Definition at line 14 of file mics_math.h.
|
inline |
x = VCC - V_ao: 0 at VCC (a saturated sensor, never clean air).
NaN at or below VENDOR_DEAD_INPUT_FRACTION of VCC (a disconnected pin) and above VCC, which only a wrong vcc or voltage_multiplier produces.
Definition at line 36 of file mics_math.h.
|
inline |
True when the clean-air samples spread at most MAX_CALIBRATION_SPREAD of their mean.
Definition at line 122 of file mics_math.h.
|
inline |
Clamp to the configured range: below min_ppm counts as not detected and reads 0, 0 itself never changes, and a reading past a finite max_ppm (infinity included) is max_ppm.
NaN stays NaN.
Definition at line 104 of file mics_math.h.
|
inline |
Smallest V_ao the datasheet model reads: the output of RS = MAX_RS_OVER_RL * RL.
Definition at line 73 of file mics_math.h.
|
inline |
ppm = a * ratio^b; NaN for a ratio or coefficient that cannot produce a reading.
Ratio 0, the saturated end, gives infinity on a falling curve, which clamp_ppm turns into max_ppm.
Definition at line 93 of file mics_math.h.
|
inline |
ratio -> ppm as DFRobot_MICS getGasData(): 0 above the threshold or below the vendor range, the top of the range at ratio 0 (a saturated sensor), NaN stays NaN.
Definition at line 51 of file mics_math.h.
|
inline |
ratio = x / x_air (NaN when either value is unusable).
Definition at line 43 of file mics_math.h.
|
inline |
ratio = RS / R0 (NaN when either value is unusable); 0 is the saturated end.
Definition at line 85 of file mics_math.h.
|
inline |
RS = (VCC * RL) / V - RL in kOhm: 0 at VCC (a saturated sensor).
NaN above VCC, which only a wrong vcc or voltage_multiplier produces, and at or below datasheet_dead_input_voltage().
Definition at line 77 of file mics_math.h.
|
inlineconstexpr |
Largest relative spread (max - min) / mean a clean-air calibration accepts.
Definition at line 119 of file mics_math.h.
|
inlineconstexpr |
Largest RS the datasheet model reads, as a multiple of RL.
The datasheet puts the clean-air resistance of a module below about 1.5 MOhm, 150 x the usual 10k RL, so an output voltage below that of this resistance is a disconnected input.
Definition at line 70 of file mics_math.h.
|
inlineconstexpr |
Share of VCC at or below which the vendor model reads the output as disconnected: clean air sits a volt or two below VCC, so a reading near 0 V is a wiring fault, not gas-free air.
Definition at line 31 of file mics_math.h.