|
| | MQ6 () |
| | Builds a default MQ-6 (LPG / propane) sensor and initializes its datasheet values. More...
|
| |
| | MQ6 (IAnalogDigitalConverterComponent *analogToDigitalConverter, const unsigned int &analogToDigitalConverterIndex, const unsigned int &digitalOutputPinNumber) |
| | Builds an MQ-6 that reads through an ADC and also exposes a digital threshold pin. More...
|
| |
| | MQ6 (IAnalogDigitalConverterComponent *analogToDigitalConverter, const unsigned int &analogToDigitalConverterIndex) |
| | Builds an analog-only MQ-6 that reads through an ADC. More...
|
| |
| | MQ6 (const unsigned int &digitalOutputPinNumber) |
| | Builds a digital-only MQ-6 that reports only its threshold-output pin. More...
|
| |
| virtual | ~MQ6 () |
| | Destroys the sensor, turning it off first. More...
|
| |
| void | Initialize () override |
| | Initializes the MQ-6's datasheet values (its propane gas curve) and precomputes a PPM value for every possible raw analog reading, since the PPM formula is expensive but the mapping never changes. More...
|
| |
| double | ReadGasValue () const override |
| | Reads the current propane PPM for the sensor's raw reading (from the precomputed cache). More...
|
| |
| double | CalculatePropanePPM (const double &sensorGasValueInVolts) const |
| | Computes the propane concentration (PPM) from the sensor's output voltage using a power-law fit of the sensor's response curve. More...
|
| |
| std::string | ToString () const override |
| | Serializes the MQ-6's gas name, raw reading, and propane PPM to a string. More...
|
| |
| virtual void | CalculateInitialR0 () |
| | Calibrates the sensor: computes and stores its clean-air resistance (R0). More...
|
| |
| | GasSensor () |
| | Builds a default gas sensor with zeroed calibration values and no ADC or digital pin. More...
|
| |
| | GasSensor (IAnalogDigitalConverterComponent *analogToDigitalConverter, const EComponentType &gasSensorType, const unsigned int &analogToDigitalConverterIndex, const unsigned int &digitalOutputPinNumber) |
| | Builds an analog gas sensor that reads through an ADC and also exposes a digital threshold pin. More...
|
| |
| | GasSensor (IAnalogDigitalConverterComponent *analogToDigitalConverter, const EComponentType &gasSensorType, const unsigned int &analogToDigitalConverterIndex) |
| | Builds an analog-only gas sensor that reads through an ADC (no digital threshold pin). More...
|
| |
| | GasSensor (const EComponentType &gasSensorType, const unsigned int &digitalOutputPinNumber) |
| | Builds a digital-only gas sensor that reports only its threshold-output pin (no ADC). More...
|
| |
| virtual | ~GasSensor () |
| | Destroys the gas sensor, turning it off first. More...
|
| |
| virtual void | TurnOn () |
| | Turns the sensor on. More...
|
| |
| virtual void | TurnOff () |
| | Turns the sensor off. More...
|
| |
| virtual void | Initialize () |
| | Initializes the sensor's datasheet values. More...
|
| |
| int | ReadRawAnalogValue () const |
| | Reads the raw analog value from the sensor's ADC channel. More...
|
| |
| int | ReadDigitalValue () |
| | Reads the sensor's digital threshold-output pin (1 when the configured gas threshold is exceeded). More...
|
| |
| virtual double | ReadGasValue () const |
| | Gets the most recently processed gas value. More...
|
| |
| virtual void | ProcessRawValues () override |
| | Reads the sensor and computes the current gas value (PPM) from the RS/R0 ratio using the datasheet's log-log curve. More...
|
| |
| virtual std::string | ToString () const override |
| | Serializes the sensor's current gas value (PPM), a rough percentage, and the raw reading to a string. More...
|
| |
| unsigned int | GetAnalogToDigitalConverterIndex () const |
| | Gets the ADC channel index this sensor reads from. More...
|
| |
| unsigned int | GetDigitalOutputPinNumber () const |
| | Gets the digital threshold-output pin (UINT_MAX if unused). More...
|
| |
| double | GetInitialValueR0 () const |
| | Gets the sensor's clean-air resistance (R0) from calibration. More...
|
| |
| double | GetResistorValueRL () const |
| | Gets the load resistor value (RL) from the sensor's datasheet. More...
|
| |
| double | GetCurrentValueRS () const |
| | Gets the sensor's current resistance (RS). More...
|
| |
| const char * | GetDetectibleConcentration () const |
| | Gets a human-readable detectable-concentration range for this sensor. More...
|
| |
| EComponentType | GetGasSensorType () const |
| | Gets this sensor's component type (which MQ sensor it is). More...
|
| |
| const char * | GetGasSensorTypeAsString () const |
| | Gets this sensor's type as a display string (e.g. More...
|
| |
| const char * | GetGasSensorTypeAsString (const EComponentType &gasSensorType) const |
| | Maps a gas-sensor component type to its display string (e.g. More...
|
| |
| IAnalogDigitalConverterComponent * | GetAnalogDigitalConverter () const |
| | Gets the ADC this sensor reads its analog value through. More...
|
| |
| const GasData & | GetGasData () const |
| | Gets the per-gas curve data (slope/intercept and concentration points) for this sensor. More...
|
| |
| | BaseComponent () |
| | Builds a base component with an unknown type and an empty name. More...
|
| |
| virtual | ~BaseComponent () |
| | Virtual destructor so deleting a component through a BaseComponent* also cleans up the concrete subclass. More...
|
| |
| virtual void | TurnOn ()=0 |
| | Turns the component on (e.g. More...
|
| |
| virtual void | TurnOff ()=0 |
| | Turns the component off. More...
|
| |
| virtual std::string | ToString () const =0 |
| | Serializes the component's current readings to a string (usually JSON). More...
|
| |
| virtual void | ProcessRawValues ()=0 |
| | Reads and processes the component's latest raw values (called once per poll). More...
|
| |
| virtual EComponentType | GetComponentType () const |
| | Gets the component's type. More...
|
| |
| const std::string & | GetName () const |
| | Gets the component's unique per-instance name. More...
|
| |
| void | SetName (const std::string &name) |
| | Sets the component's unique per-instance name. More...
|
| |
|
| static std::string | ComponentTypeToString (const EComponentType theComponentTypeToConvert) |
| | Maps an EComponentType to its string name. More...
|
| |
| static EComponentType | StringToComponentType (const std::string &theComponentTypeName) |
| | Maps a type name back to its EComponentType (the inverse of ComponentTypeToString), so the client can turn the type carried on the wire back into a value it can look an icon up with. More...
|
| |
| static constexpr double | GAS_SENSOR_VOLTAGE = 5.0 |
| | The supply voltage the gas sensor runs on. More...
|
| |
| static const int | CALIBRATION_SAMPLE_TIMES = 200 |
| | The number of samples taken during the calibration phase. More...
|
| |
| static const int | CALIBRATION_SAMPLE_INTERVAL = 250 |
| | Milliseconds between samples during the calibration phase. More...
|
| |
| static const int | READ_SAMPLE_INTERVAL = 250 |
| | Milliseconds between samples during normal operation. More...
|
| |
| virtual double | CalculateR0 () |
| | Samples the sensor many times in clean air, averages the reading, converts it to resistance (RS), and divides by the clean-air factor to get R0. More...
|
| |
| virtual double | CalculateRS (const double &sensorValueInVolts) const |
| | Computes the sensor's resistance (RS) from its output voltage, using the load resistor RL and supply voltage. More...
|
| |
| virtual double | CalculateRSR0Ratio (const double &sensorValueInVolts) const |
| | Computes the RS/R0 ratio (used to look up PPM on the datasheet curve) from the sensor's output voltage. More...
|
| |
| double | ConvertRawSensorValueToVolts (const double &rawGasSensorValue) const |
| | Converts a raw analog reading to its equivalent voltage (using the sensor's supply voltage and the ADC's maximum value). More...
|
| |
| double | ConvertVoltsToRawSensorValue (const double &volts) const |
| | Converts a voltage back to its equivalent raw analog value (the inverse of ConvertRawSensorValueToVolts). More...
|
| |
| double | GetAnalogToDigitalConverterMaxRawValue () const |
| | Gets the ADC's full-scale raw count for scaling raw readings to volts (PCF8591 = 255 8-bit, MCP3008 = 1023 10-bit), falling back to the 10-bit convention when no ADC is wired. More...
|
| |
| double | GetAnalogToDigitalConverterVoltage () const |
| | Gets the ADC's reference voltage for scaling raw readings to volts (defined by the wired ADC, e.g. More...
|
| |
| unsigned int | myAnalogToDigitalConverterIndex |
| | The ADC channel index this sensor reads its analog value from. More...
|
| |
| unsigned int | myDigitalOutputPinNumber |
| | The digital output (threshold) pin, or UINT_MAX if unused. More...
|
| |
| double | myInitialValueR0 |
| | The sensor's resistance in clean air (R0), from calibration. More...
|
| |
| double | myResistorValueRL |
| | The load resistor value (RL) from the sensor's datasheet. More...
|
| |
| double | myCurrentValueRS |
| | The sensor's current resistance (RS). More...
|
| |
| double | myCleanAirFactor |
| | The clean-air factor (RS/R0 in clean air) from the datasheet. More...
|
| |
| double | myRawGasSensorValue |
| | The most recent raw analog reading. More...
|
| |
| double | myCurrentGasValue |
| | The most recent computed gas value (PPM). More...
|
| |
| const char * | myDetectibleConcentration |
| | A human-readable detectable-concentration range for this sensor. More...
|
| |
| IAnalogDigitalConverterComponent * | myAnalogToDigitalConverter |
| | The ADC this sensor reads its analog value through. More...
|
| |
| GasData | myGasData |
| | Per-gas curve data (slope/intercept) used to convert the RS/R0 ratio to PPM. More...
|
| |
| EComponentType | myComponentType |
| | The kind of component this is (set by each concrete subclass). More...
|
| |
| std::string | myName |
| | A unique per-instance name, assigned when the component is added to the manager. More...
|
| |
MQ-6 gas sensor, typically used for detecting LPG and propane.
- Author
- Eddie O'Hagan
- Date
- 8/13/2026