Updated analisis

This commit is contained in:
miguel5612 2019-08-15 20:47:42 -05:00
parent f46a9f6651
commit 9d69abbdd9
11 changed files with 105 additions and 130 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -105,6 +105,7 @@ void MQUnifiedsensor::inicializar()
float MQUnifiedsensor::readSensor(String nameLectureRequeired, bool print)
{
setSensorCharacteristics(nameLectureRequeired, print); //In this function update _a and _b
//More explained in: https://jayconsystems.com/blog/understanding-a-gas-sensor
_RS_Calc = ((_VOLT_RESOLUTION*_RLValue)/_sensor_volt)-_RLValue; //Get value of RS in a gas
_ratio = _RS_Calc / this->_R0; // Get ratio RS_gas/RS_air
_PPM= _a*pow(_ratio, _b);
@ -137,15 +138,6 @@ void MQUnifiedsensor::setSensorCharacteristics(String nameLectureRequeired, bool
nameLectureRequeired = _nameLectureRequeired;
}
//Dinamic index search
/*
for (int i=0; i<sizeof(_MQ); i++) {
if (nameLectureRequeired == _MQ[i]) { //modified here
_lecturePosInArray = i;
break;
}
}
*/
if(_type == 2)
{
if(nameLectureRequeired == "H2")

View File

@ -5,9 +5,6 @@
#include <stdint.h>
//Count of posible lectures
#define lecturesAvailable 19
//Index in the nameLecture vector
#define defaultMQ2 "LPG" // LPG
#define defaultMQ3 "Alcohol" // Alcohol
@ -64,23 +61,22 @@
//Values consolidated
//Equation PPM = a*((x)^b)
/********************** MQ2 ******************************************************/
#define MQ2_H2_a -2.2459
#define MQ2_H2_b 2.9845
#define MQ2_H2_a 987.99
#define MQ2_H2_b -2.162
#define MQ2_LPG_a -2.2879
#define MQ2_LPG_b 2.7901
#define MQ2_LPG_a 574.25
#define MQ2_LPG_b -2.222
#define MQ2_CO_a -2.6208
#define MQ2_CO_b 3.6075
#define MQ2_CO_a 36974
#define MQ2_CO_b -3.109
#define MQ2_Alcohol_a -3.1157
#define MQ2_Alcohol_b 4.5134
#define MQ2_Alcohol_a 3616.1
#define MQ2_Alcohol_b -2.675
#define MQ2_Propane_a 658.71
#define MQ2_Propane_b -2.168
#define MQ2_Propane_a -2.7028
#define MQ2_Propane_b 3.5595
#define MQ2_Benzene_a -2.2879
#define MQ2_Benzene_b 2.7901
/********************** MQ3 ******************************************************/
#define MQ3_LPG_a 44771
@ -95,173 +91,160 @@
#define MQ3_Alcohol_a 0.3934
#define MQ3_Alcohol_b -1.504
#define MQ3_Benzene_a 1.8006
#define MQ3_Benzene_b -0.373
#define MQ3_Benzene_a 4.8387
#define MQ3_Benzene_b -2.68
#define MQ3_Hexane_a 22.996
#define MQ3_Hexane_b -0.351
#define MQ3_Hexane_a 7585.3
#define MQ3_Hexane_b -2.849
/********************** MQ4 ******************************************************/
#define MQ4_LPG_a -2.5818
#define MQ4_LPG_b 3.6303
#define MQ4_LPG_a 3811.9
#define MQ4_LPG_b -3.113
#define MQ4_CH4_a 0.9873
#define MQ4_CH4_b 2.6386
#define MQ4_CH4_a 1012.7
#define MQ4_CH4_b -2.786
#define MQ4_CO_a -5.5945
#define MQ4_CO_b 5.6693
#define MQ4_CO_a 200000000000000
#define MQ4_CO_b -19.05
#define MQ4_Alcohol_a -11.89
#define MQ4_Alcohol_b 9.0375
#define MQ4_Alcohol_a 60000000000
#define MQ4_Alcohol_b -14.01
#define MQ4_smoke_a -11.189
#define MQ4_smoke_b 9.0375
#define MQ4_smoke_a 30000000
#define MQ4_smoke_b -8.308
/********************** MQ5 ******************************************************/
#define MQ5_H2_a -4.368
#define MQ5_H2_b 2.9667
#define MQ5_H2_a 1163.8
#define MQ5_H2_b -3.874
#define MQ5_LPG_a -2.5723
#define MQ5_LPG_b 1.8943
#define MQ5_LPG_a 80.897
#define MQ5_LPG_b -2.431
#define MQ5_CH4_a -2.4438
#define MQ5_CH4_b 2.3044
#define MQ5_CH4_a 177.65
#define MQ5_CH4_b -2.56
#define MQ5_CO_a -4.8188
#define MQ5_CO_b 5.2023
#define MQ5_Alcohol_a -4.419
#define MQ5_Alcohol_b 4.8044
#define MQ5_CO_a 491204
#define MQ5_CO_b -5.826
#define MQ5_Alcohol_a 97124
#define MQ5_Alcohol_b -4.918
/********************** MQ6 ******************************************************/
#define MQ6_H2_a -3.6775
#define MQ6_H2_b 5.0286
#define MQ6_H2_a 88158
#define MQ6_H2_b -3.597
#define MQ6_LPG_a -1.6567
#define MQ6_LPG_b 2.8775
#define MQ6_LPG_a 1009.2
#define MQ6_LPG_b -2.35
#define MQ6_CH4_a -1
#define MQ6_CH4_b 3.301
#define MQ6_CH4_a 2127.2
#define MQ6_CH4_b -2.526
#define MQ6_CO_a -12.791
#define MQ6_CO_b 14.523
#define MQ6_CO_a 1000000000000000
#define MQ6_CO_b -13.5
#define MQ6_Alcohol_a -5.8057
#define MQ6_Alcohol_b 7.5292
#define MQ6_Alcohol_a 50000000
#define MQ6_Alcohol_b -6.017
/********************** MQ7 ******************************************************/
#define MQ7_H2_a -1.329
#define MQ7_H2_b 1.8864
#define MQ7_H2_a 69.014
#define MQ7_H2_b -1.374
#define MQ7_LPG_a -7.8626
#define MQ7_LPG_b 9.1056
#define MQ7_LPG_a 700000000
#define MQ7_LPG_b -7.703
#define MQ7_CH4_a -5.4878
#define MQ7_CH4_b 8.8387
#define MQ7_CH4_a 60000000000000
#define MQ7_CH4_b -10.54
#define MQ7_CO_a -1.4065
#define MQ7_CO_b 2.0162
#define MQ7_CO_a 99.042
#define MQ7_CO_b -1.518
#define MQ7_Alcohol_a -6.3219
#define MQ7_Alcohol_b 9.924
#define MQ7_Alcohol_a 40000000000000000
#define MQ7_Alcohol_b -12.35
/********************** MQ8 ******************************************************/
#define MQ8_H2_a -0.7152
#define MQ8_H2_b 2.9891
#define MQ8_H2_a 976.97
#define MQ8_H2_b -0.688
#define MQ8_LPG_a -3.419
#define MQ8_LPG_b 7.3513
#define MQ8_LPG_a 10000000
#define MQ8_LPG_b -3.123
#define MQ8_CH4_a -7.5609
#define MQ8_CH4_b 15.243
#define MQ8_CH4_a 80000000000000
#define MQ8_CH4_b -6.666
#define MQ8_CO_a -7.0753
#define MQ8_CO_b 15.396
#define MQ8_CO_a 2000000000000000000
#define MQ8_CO_b -8.074
#define MQ8_Alcohol_a -1.7459
#define MQ8_Alcohol_b 4.7575
#define MQ8_Alcohol_a 76101
#define MQ8_Alcohol_b -1.86
/********************** MQ9 ******************************************************/
#define MQ9_LPG_a -2.2535
#define MQ9_LPG_b 2.9855
#define MQ9_LPG_a 1000.5
#define MQ9_LPG_b -2.186
#define MQ9_CH4_a -1.6012
#define MQ9_CH4_b 3.1476
#define MQ9_CH4_a 4269.6
#define MQ9_CH4_b -2.648
#define MQ9_CO_a -1.749
#define MQ9_CO_b 2.827
#define MQ9_CO_a 599.65
#define MQ9_CO_b -2.244
/********************** MQ131 ******************************************************/
#define MQ131_NOx_a -2.7245
#define MQ131_NOx_b 3.3004
#define MQ131_NOx_a -462.43
#define MQ131_NOx_b -2.204
#define MQ131_CL2_a -1.0333
#define MQ131_CL2_b 1.7117
#define MQ131_CL2_a 47.209
#define MQ131_CL2_b -1.186
#define MQ131_O3_a -1.2037
#define MQ131_O3_b 1.6455
#define MQ131_O3_a 23.943
#define MQ131_O3_b -1.11
/********************** MQ135 ******************************************************/
#define MQ135_CO_a -2.7268
#define MQ135_CO_b 2.301
#define MQ135_CO_a 605.18
#define MQ135_CO_b -3.937
#define MQ135_Alcohol_a -2.8608
#define MQ135_Alcohol_b 1.8627
#define MQ135_Alcohol_a 77.255
#define MQ135_Alcohol_b -3.18
#define MQ135_CO2_a -3.2819
#define MQ135_CO2_b 1.9903
#define MQ135_CO2_a 110.47
#define MQ135_CO2_b -2.862
#define MQ135_Tolueno_a -5.7015
#define MQ135_Tolueno_b 1.1612
#define MQ135_Tolueno_a 44.947
#define MQ135_Tolueno_b -3.445
#define MQ135_NH4_a -2.2119
#define MQ135_NH4_b 2.0473
#define MQ135_NH4_a 102.2
#define MQ135_NH4_b -2.473
#define MQ135_Acetona_a -5.9682
#define MQ135_Acetona_b 1.0175
#define MQ135_Acetona_a 34.668
#define MQ135_Acetona_b -3.369
/********************** MQ303 ******************************************************/
#define MQ303_Iso_butano_a -2.3543
#define MQ303_Iso_butano_b 1.144
#define MQ303_Iso_butano_a 6.2144
#define MQ303_Iso_butano_b -2.894
#define MQ303_Hydrogeno_a -2.4338
#define MQ303_Hydrogeno_b 0.7558
#define MQ303_Hydrogeno_a 4.1487
#define MQ303_Hydrogeno_b -2.716
#define MQ303_Ethanol_a -2.5597
#define MQ303_Ethanol_b 0.4436
#define MQ303_Ethanol_a 3.4916
#define MQ303_Ethanol_b -2.432
/********************** MQ309 ******************************************************/
#define MQ309_H2_a -2.1311
#define MQ309_H2_b 3.0886
#define MQ309_H2_a 1532.9
#define MQ309_H2_b -1.951
#define MQ309_CH4_a -1.6554
#define MQ309_CH4_b 2.985
#define MQ309_CH4_a 980.24
#define MQ309_CH4_b -1.68
#define MQ309_CO_a -4.7623
#define MQ309_CO_b 6.7413
#define MQ309_CO_a 1000000
#define MQ309_CO_b -4.01
#define MQ309_Alcohol_a -3.7686
#define MQ309_Alcohol_b 5.6744
#define MQ309_Alcohol_a 473622
#define MQ309_Alcohol_b -3.647
/*
const String _MQ2[18] = {"H2","-2.2459","2.9845","LPG","-2.2879","2.7901","CO","-2.6208","3.6075","Alcohol","-3.1157","4.5134","Propane","-2.7028","3.5595","Benzene","-2.2879","2.7901"};
const String _MQ3[18] = {"LPG","-3.1851","4.7048","CH4","-17.531","28.785","CO","-4.339","6.4432","Alcohol","-1.435","0.4103","Benzene","-2.7009","0.632","Hexane","-2.7268","3.6299"};
const String _MQ4[15] = {"LPG","-2.5818","3.6303","CH4","0.9873","2.6386","CO","-5.5945","5.6693","Alcohol","-11.89","9.0375","smoke","-11.189","9.0375"};
const String _MQ5[15] = {"H2","-4.368","2.9667","LPG","-2.5723","1.8943","CH4","-2.4438","2.3044","CO","-4.8188","5.2023","Alcohol","-4.419","4.8044"};
const String _MQ6[15] = {"H2","-3.6775","5.0286","LPG","-1.6567","2.8775","CH4","-1","3.301","CO","-12.791","14.523","Alcohol","-5.8057","7.5292"};
const String _MQ7[15] = {"H2","-1.329","1.8864","LPG","-7.8626","9.1056","CH4","-5.4878","8.8387","CO","-1.4065","2.0162","Alcohol","-6.3219","9.924"};
const String _MQ8[15] = {"H2","-0.7152","2.9891","LPG","-3.419","7.3513","CH4","-7.5609","15.243","CO","-7.0753","15.396","Alcohol","-1.7459","4.7575"};
const String _MQ9[9] = {"LPG","-2.2535","2.9855","CH4","-1.6012","3.1476","CO","-1.749","2.827"};
const String _MQ131[9] = {"Nox","-2.7245","3.3004","CL2","-1.0333","1.7117","O3","-1.2037","1.6455"};
const String _MQ135[18] = {"CO","-2.7268","2.301","Alcohol","-2.8608","1.8627","CO2","-3.2819","1.9903","Tolueno","-5.7015","1.1612","NH4","-2.2119","2.0473","Acetona","-5.9682","1.0175"};
const String _MQ303A[9] = {"Iso-butano","-2.3543","1.144","Hydrogeno","-2.4338","0.7558","Ethanol","-2.5597","0.4436"};
const String _MQ309A[12] = {"H2","-2.1311","3.0886","CH4","-1.6554","2.985","CO","-4.7623","6.7413","Alcohol","-3.7686","5.6744"};
*/
class MQUnifiedsensor
{