upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
Public Member Functions

API for the MQ9 Gas Sensor. More...

Detailed Description

The Grove MQ9 Gas Sensor module is useful for gas leakage detection (in home and industry). It can detect carbon monoxide, coal gas, and liquefied gas. Its sensitivity is 10-1,000 ppm CO, and 100-10,000 ppm Gas.

mq3-9.jpeg
int
main(int argc, char** argv)
{
upm::MQ9 sensor(0);
signal(SIGINT, sig_handler);
ctx.averageReading = 0;
ctx.runningAverage = 0;
ctx.averagedOver = 2;
while (!is_running) {
int len = sensor.getSampledWindow(2, 128, buffer);
if (len) {
int thresh = sensor.findThreshold(&ctx, 30, buffer, len);
sensor.printGraph(&ctx, 5);
if (thresh) {
// do something ....
}
}
}
std::cout << "exiting application" << std::endl;
return 0;
}

Public Member Functions

 MQ9 (int gasPin)
 
 ~MQ9 ()
 
std::string name ()
 
- Public Member Functions inherited from Gas
 Gas (int gasPin)
 
virtual ~Gas ()
 
virtual int getSampledWindow (unsigned int freqMS, int numberOfSamples, uint16_t *buffer)
 
virtual int findThreshold (thresholdContext *ctx, unsigned int threshold, uint16_t *buffer, int len)
 
virtual int getSampledData (thresholdContext *ctx)
 
virtual int getSample ()
 
virtual void printGraph (thresholdContext *ctx, uint8_t resolution)
 

Additional Inherited Members

- Protected Attributes inherited from Gas
mraa::Aio m_aio
 

Constructor & Destructor Documentation

MQ9 ( int  gasPin)

MQ9 constructor

Parameters
gasPinAnalog pin where the sensor is connected
~MQ9 ( )

MQ9 destructor

Member Function Documentation

std::string name ( )
inline

Returns the name of the sensor

Inheritance diagram for MQ9:
Inheritance graph
[legend]
Collaboration diagram for MQ9:
Collaboration graph
[legend]

The documentation for this class was generated from the following files: