RumPi 1.0
A self-assembling C++ sensor & actuator library for the Raspberry Pi 5
MQ3.h
Go to the documentation of this file.
1#pragma once
2#include "../Common.h"
3#include "GasSensor.h"
4
5namespace RumPi
6{
14 class MQ3 : public GasSensor
15 {
16 public:
27 MQ3();
28
43 MQ3(IAnalogDigitalConverterComponent* analogToDigitalConverter, const unsigned int& analogToDigitalConverterIndex, const unsigned int& digitalOutputPinNumber);
44
58 MQ3(IAnalogDigitalConverterComponent* analogToDigitalConverter, const unsigned int& analogToDigitalConverterIndex);
59
72 MQ3(const unsigned int& digitalOutputPinNumber);
73
85 virtual ~MQ3();
86
98 void Initialize() override;
99
112 double ReadGasValue() const override;
113
129 double CalculateBAC(const double& sensorValueInVolts) const;
130
143 std::string ToString() const override;
144 };
145} // 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-3 gas sensor, typically used for detecting alcohol vapor (breathalyzer).
Definition: MQ3.h:15
double CalculateBAC(const double &sensorValueInVolts) const
Estimates blood-alcohol content (BAC) from the sensor's output voltage using a 5th-degree polynomial ...
Definition: MQ3.cpp:148
MQ3()
Builds a default MQ-3 (alcohol) sensor and initializes its datasheet values.
Definition: MQ3.cpp:15
virtual ~MQ3()
Destroys the sensor, turning it off first.
Definition: MQ3.cpp:85
std::string ToString() const override
Serializes the MQ-3's raw reading and estimated BAC to a string.
Definition: MQ3.cpp:176
void Initialize() override
Initializes the MQ-3's datasheet values (its alcohol gas curve) and precomputes a BAC value for every...
Definition: MQ3.cpp:101
double ReadGasValue() const override
Reads the current estimated BAC for the sensor's raw reading (from the precomputed cache).
Definition: MQ3.cpp:128
RumPi is the library's top-level facade.
Definition: AlertManager.h:6