ESPHome 2026.11.0-dev
Loading...
Searching...
No Matches
esphome::mics_5524::micsmath Namespace Reference

Data Structures

struct  VendorCurve
 Per-gas constants of the vendor model. More...
 

Functions

float air_value_from_voltage (float voltage, float vcc)
 x = VCC - V_ao: 0 at VCC (a saturated sensor, never clean air).
 
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.
 
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.
 

Variables

constexpr float MAX_CALIBRATION_SPREAD = 0.25f
 Largest relative spread (max - min) / mean a clean-air calibration accepts.
 

Function Documentation

◆ air_value_from_voltage()

float esphome::mics_5524::micsmath::air_value_from_voltage ( float voltage,
float vcc )
inline

x = VCC - V_ao: 0 at VCC (a saturated sensor, never clean air).

NaN at or below 0 V (a disconnected pin) and above VCC, which only a wrong vcc or voltage_multiplier produces.

Definition at line 20 of file mics_math.h.

◆ calibration_is_stable()

bool esphome::mics_5524::micsmath::calibration_is_stable ( float min_value,
float max_value,
float mean )
inline

True when the clean-air samples spread at most MAX_CALIBRATION_SPREAD of their mean.

Definition at line 30 of file mics_math.h.

◆ ppm_from_vendor_curve()

float esphome::mics_5524::micsmath::ppm_from_vendor_curve ( float ratio,
const VendorCurve & curve )
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 45 of file mics_math.h.

◆ ratio_from_air_value()

float esphome::mics_5524::micsmath::ratio_from_air_value ( float x,
float x_air )
inline

ratio = x / x_air (NaN when either value is unusable).

Definition at line 37 of file mics_math.h.

Variable Documentation

◆ MAX_CALIBRATION_SPREAD

float esphome::mics_5524::micsmath::MAX_CALIBRATION_SPREAD = 0.25f
inlineconstexpr

Largest relative spread (max - min) / mean a clean-air calibration accepts.

Definition at line 27 of file mics_math.h.