A library for the MQ2 sensor. Based on https://github.com/labay11 and http://sandboxelectronics.com/?p=165
Dependents: mq2_example mq2_midtermproject ECE595_Group9_FinalProject mq2_example ... more
Diff: MQ2.h
- Revision:
- 1:323f72b59e99
- Parent:
- 0:a5033edf6975
- Child:
- 3:ed294e830904
diff -r a5033edf6975 -r 323f72b59e99 MQ2.h --- a/MQ2.h Thu Oct 05 11:33:31 2017 +0000 +++ b/MQ2.h Thu Oct 05 12:03:38 2017 +0000 @@ -4,15 +4,15 @@ #include "mbed.h" #define RL_VALUE 5 //define the load resistance on the board, in kilo ohms -#define RO_DEFAULT 10 -#define RO_CLEAN_AIR_FACTOR 9.83f -#define CALIBARAION_SAMPLE_TIMES 5 -#define CALIBRATION_SAMPLE_INTERVAL 50 -#define READ_SAMPLE_INTERVAL 50 -#define READ_SAMPLE_TIMES 5 +#define RO_DEFAULT 10 //Ro is initialized to 10 kilo ohms +#define RO_CLEAN_AIR_FACTOR 9.83f //RO_CLEAR_AIR_FACTOR=(Sensor resistance in clean air)/RO, which is derived from the chart in datasheet +#define CALIBARAION_SAMPLE_TIMES 5 //define how many samples you are going to take in the calibration phase +#define CALIBRATION_SAMPLE_INTERVAL 50 //define the time interal(in milisecond) between each samples +#define READ_SAMPLE_INTERVAL 50 //define how many samples you are going to take in normal operation +#define READ_SAMPLE_TIMES 5 //define the time interal(in milisecond) between each samples //The curves -static float LPGCurve[] = {2.3f,0.21f,-0.47f}; +static float LPGCurve[] = {2.3f,0.21f,-0.47f}; static float COCurve[] = {2.3f,0.72f,-0.34f}; static float SmokeCurve[] = {2.3f,0.53f,-0.44f};