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

API for the MQ303A Alcohol Sensor. More...

Detailed Description

UPM module for the MQ303A alcohol sensor. This sensor needs to be warmed up before stable results are obtained. The higher the value returned from value(), the higher the amount of alcohol detected.

mq303a.jpg
// Instantiate an mq303a sensor on analog pin A0
// This device uses a heater powered from an analog I/O pin.
// If using A0 as the data pin, then you need to use A1, as the heater
// pin (if using a grove mq303a). For A1, we can use the D15 gpio,
// setup as an output, and drive it low to power the heater.
upm::MQ303A mq303a(0, 15);
cout << "Enabling heater and waiting 2 minutes for warmup." << endl;
mq303a.heaterEnable(true);
upm_delay(120);
cout << "This sensor may need to warm until the value drops below about 450." << endl;
// Print the detected alcohol value every second
while (shouldRun) {
int val = mq303a.value();
cout << "Alcohol detected (higher means stronger alcohol): " << val << endl;
upm_delay(1);
}

Public Member Functions

 MQ303A (int pin, int heaterPin)
 
 ~MQ303A ()
 
int value ()
 
void heaterEnable (bool enable)
 

Constructor & Destructor Documentation

MQ303A ( int  pin,
int  heaterPin 
)

MQ303A constructor

Parameters
pinAnalog pin to use
heaterPinDigital pin mapped to the analog pin to use
~MQ303A ( )

MQ303A destructor

Here is the call graph for this function:

Member Function Documentation

int value ( )

Gets the alcohol reading from the sensor. The value read from the analog pin is inverted. A higher returned value means a higher amount of alcohol detected.

Returns
Alcohol reading
void heaterEnable ( bool  enable)

Enables the heater

Parameters
enableEnables the heater if true; otherwise, disables it

Here is the caller graph for this function:


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