upm  0.1.8
Sensor/Actuator repository for libmraa (v0.4.5)
 All Data Structures Files Functions Variables Macros Pages
Public Member Functions
MQ3 Class Reference

C++ API for MQ3 gas sensor. More...

Detailed Description

The Grove MQ3 Gas Sensor module is useful for gas leakage detecting (in home and industry). It can detect Alcohol Vapour and Benzine. It's highly sensitive but has a long warmup time of about 1minute. It's detect rate is of 0.04-4mg/L Alcohol.

int
main(int argc, char **argv)
{
sensor = new upm::MQ3(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;
delete sensor;
return 0;
}
grovegas.jpeg

Public Member Functions

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

Additional Inherited Members

- Protected Attributes inherited from Gas
mraa_aio_context m_gasCtx
 

Constructor & Destructor Documentation

MQ3 ( int  gasPin)

MQ3 constructor

Parameters
gasPinanalog pin where sensor connected
~MQ3 ( )

MQ3 destructor

Member Function Documentation

std::string name ( )
inline

Return name of the component

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

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