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

API for the Grove TP401 Air Quality Sensor. More...

Detailed Description

The Grove TP401 Air Quality Sensor module is useful for monitoring air purity indoors. It can detect CO and a wide range of other harmful gases, but, due to a limited detection range, it should be used only when qualitative results are needed. Example applications are air recirculation, ventilation systems, and refreshing sprayers. The sensor is linear and should be roughly sensitive to 0-20 ppm CO from 0-4 V. Note: the sensor requires 2-3 minutes to warm up initially and 48 hours of operation to stabilize completely.

tp401.jpeg
// Instantiate new grove air quality sensor on analog pin A0
upm_gas.TP401 airSensor = new upm_gas.TP401(0);
System.out.println(airSensor.name());
System.out.println("Heating sensor for 3 minutes...");
// wait 3 minutes for sensor to warm up
for (int i = 0; i < 3; i++) {
if (i != 0)
System.out.println("Please wait, " + i + " minute(s) passed..");
Thread.sleep(60000);
}
System.out.println("Sensor ready!");
while (true) {
int value = airSensor.getSample(); // Read raw value
float ppm = airSensor.getPPM(); // Read CO ppm (can vary slightly
// from previous read)
System.out.println("raw: " + value + " ppm: " + ppm + " " + airQuality(value));
Thread.sleep(100);
}

Public Member Functions

synchronized void delete ()
 
 TP401 (int gasPin)
 
String name ()
 
float getPPM ()
 
- 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

TP401 ( int  gasPin)

TP401 constructor

Parameters
gasPinAnalog pin where the sensor is connected

Member Function Documentation

float getPPM ( )

Returns one sample in parts per million (ppm) of CO in the air based on the following sensor calibration: 0-4 V is roughly 0-20 ppm CO

Returns
New sample converted to ppm CO
String name ( )

Returns the name of the sensor

Returns
Name of the sensor
Inheritance diagram for TP401:
Inheritance graph
[legend]
Collaboration diagram for TP401:
Collaboration graph
[legend]

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