Paul Grant / MQ135

Dependents:   gather_sensor_data

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers MQ135.h Source File

MQ135.h

Go to the documentation of this file.
00001 /**************************************************************************/
00002 /*!
00003 @file     MQ135.h
00004 @author   G.Krocker (Mad Frog Labs)
00005 @license  GNU GPLv3
00006 
00007 First version of an Arduino Library for the MQ135 gas sensor
00008 TODO: Review the correction factor calculation. This currently relies on
00009 the datasheet but the information there seems to be wrong.
00010 
00011 @section  HISTORY
00012 
00013 v1.0 - First release
00014 */
00015 /**************************************************************************/
00016 #ifndef MQ135_H
00017 #include "mbed.h"
00018 
00019 #define MQ135_H
00020 
00021 /// The load resistance on the board
00022 #define RLOAD 10.0
00023 /// Calibration resistance at atmospheric CO2 level
00024 #define RZERO 76.63
00025 /// Parameters for calculating ppm of CO2 from sensor resistance
00026 #define PARA 116.6020682
00027 #define PARB 2.769034857
00028 
00029 /// Parameters to model temperature and humidity dependence
00030 #define CORA 0.00035
00031 #define CORB 0.02718
00032 #define CORC 1.39538
00033 #define CORD 0.0018
00034 
00035 /// Atmospheric CO2 level for calibration purposes
00036 #define ATMOCO2 397.13
00037 
00038 class MQ135 {
00039  private:
00040   PinName _pin;
00041 
00042  public:
00043   MQ135(PinName pin);
00044   ~MQ135();
00045   float getCorrectionFactor(float t, float h);
00046   float getResistance();
00047   float getCorrectedResistance(float t, float h);
00048   float getPPM();
00049   float getCorrectedPPM(float t, float h);
00050   float getRZero();
00051   float getCorrectedRZero(float t, float h);
00052 };
00053 #endif