upm  0.4.1
Sensor/Actuator repository for libmraa (v0.8.0)
Public Member Functions | List of all members

API for the MQ5 Gas Sensor. More...

Detailed Description

The Grove MQ5 Gas Sensor module is useful for gas leakage detection (in home and industry). It can detect LPG, natural gas, town gas, and so on. It is highly sensitive and has a detection range of 300-10,000 ppm.

mq2-5.jpeg
short[] buffer = new short[128];
// Attach gas sensor to A0
upm_gas.MQ5 sensor = new upm_gas.MQ5(0);
ctx.setAverageReading(0);
ctx.setRunningAverage(0);
ctx.setAveragedOver(2);
while (true) {
int len = sensor.getSampledWindow(2, buffer);
if (len != 0) {
int thresh = sensor.findThreshold(ctx, 30, buffer);
sensor.printGraph(ctx, resolution);
if (thresh != 0) {
System.out.println("---Threshold reached---");
}
}
Thread.sleep(1000);
}

Public Member Functions

synchronized void delete ()
 
 MQ5 (int gasPin)
 
String name ()
 
- Public Member Functions inherited from Gas
synchronized void delete ()
 
 Gas (int gasPin)
 
int getSampledWindow (long freqMS, short[] numberOfSamples)
 
int findThreshold (thresholdContext ctx, long threshold, short[] buffer)
 
int getSampledData (thresholdContext ctx)
 
int getSample ()
 
void printGraph (thresholdContext ctx, short resolution)
 

Constructor & Destructor Documentation

MQ5 ( int  gasPin)

MQ5 constructor

Parameters
gasPinAnalog pin where the sensor is connected

Member Function Documentation

String name ( )

Returns the name of the sensor

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

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