RumPi 1.0
A self-assembling C++ sensor & actuator library for the Raspberry Pi 5
MQ5.h
Go to the documentation of this file.
1#pragma once
2#include "../Common.h"
3#include "GasSensor.h"
4
5namespace RumPi
6{
13 class MQ5 : public GasSensor
14 {
15 public:
26 MQ5();
27
42 MQ5(IAnalogDigitalConverterComponent* analogToDigitalConverter, const unsigned int& analogToDigitalConverterIndex, const unsigned int& digitalOutputPinNumber);
43
57 MQ5(IAnalogDigitalConverterComponent* analogToDigitalConverter, const unsigned int& analogToDigitalConverterIndex);
58
71 MQ5(const unsigned int& digitalOutputPinNumber);
72
84 virtual ~MQ5();
85
97 void Initialize() override;
98
111 double ReadGasValue() const override;
112
128 double CalculatePropanePPM(const double& sensorGasValueInVolts) const;
129
142 std::string ToString() const override;
143 };
144} // namespace RumPi
Base class for the MQ-series gas sensors (MQ2, MQ7, ...).
Definition: GasSensor.h:19
Interface for analog-to-digital converter components (e.g.
Definition: AnalogDigitalConverterComponent.h:14
MQ-5 gas sensor, typically used for detecting LPG and natural gas (propane).
Definition: MQ5.h:14
MQ5()
Builds a default MQ-5 (LPG / propane) sensor and initializes its datasheet values.
Definition: MQ5.cpp:15
double ReadGasValue() const override
Reads the current propane PPM for the sensor's raw reading (from the precomputed cache).
Definition: MQ5.cpp:129
void Initialize() override
Initializes the MQ-5's datasheet values (its propane gas curve) and precomputes a PPM value for every...
Definition: MQ5.cpp:101
virtual ~MQ5()
Destroys the sensor, turning it off first.
Definition: MQ5.cpp:85
double CalculatePropanePPM(const double &sensorGasValueInVolts) const
Computes the propane concentration (PPM) from the sensor's output voltage using a power-law fit of th...
Definition: MQ5.cpp:149
std::string ToString() const override
Serializes the MQ-5's gas name, raw reading, and propane PPM to a string.
Definition: MQ5.cpp:169
RumPi is the library's top-level facade.
Definition: AlertManager.h:6