Updated sample and code

This commit is contained in:
miguel5612 2019-05-28 21:54:56 -05:00
parent cbb3599a9f
commit 1a4c91528d
3 changed files with 28 additions and 19 deletions

Binary file not shown.

View File

@ -9,6 +9,14 @@
modified 27 May 2019
by Miguel Califa
Added LCD
modified 26 May 2019
by Miguel Califa
Changed sample frecuency
modified 28 May 2019
by Ghiordy contreras, Miguel Califa
This example code is in the public domain.
*/
@ -32,6 +40,7 @@ LiquidCrystal_I2C lcd(0x27, 16, 2);
#define pin8 A8 //Analog input 8 of your arduino
#define pin9 A9 //Analog input 9 of your arduino
#define timeDelay 500
//Declare Sensor
MQUnifiedsensor MQ2(pin2, 2);
@ -67,14 +76,14 @@ void setup() {
MQ6.inicializar();
MQ7.inicializar();
MQ8.inicializar();
//MQ9.inicializar();
MQ9.inicializar();
//Print in serial monitor
Serial.println("MQ2 to MQ9 - Calibracion");
Serial.println("Note - Make sure you are in a clean room and the sensor has pre-heated almost 4 hours");
Serial.println("Autonumeric, MQ2(PPM), MQ3(PPM), MQ4(PPM), MQ5(PPM), MQ6(PPM), MQ7(PPM)");
//Wait one second to continue
delay(1000);
delay(timeDelay/10);
}
void loop() {
@ -103,7 +112,7 @@ void loop() {
lcd.print("MQ3: ");
lcd.print(lecture3);
lcd.print(" PPM");
delay(2000);
delay(timeDelay/4);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("MQ4: ");
@ -113,7 +122,7 @@ void loop() {
lcd.print("MQ5: ");
lcd.print(lecture5);
lcd.print(" PPM");
delay(2000);
delay(timeDelay/4);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("MQ6: ");
@ -123,7 +132,7 @@ void loop() {
lcd.print("MQ7: ");
lcd.print(lecture7);
lcd.print(" PPM");
delay(2000);
delay(timeDelay/4);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("MQ8: ");
@ -133,10 +142,10 @@ void loop() {
lcd.print("MQ8: ");
lcd.print(lecture8);
lcd.print(" PPM");
delay(2000);
delay(timeDelay/4);
//Increment counter
contador++;
//Wait to measure next sample
delay(400);
delay(timeDelay/4);
}

View File

@ -40,18 +40,18 @@
//Values consolidated
/* Gas, Value of m (Slope) and b (Cut on x axis) points */
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"};
const String PROGMEM _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 PROGMEM _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 PROGMEM _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 PROGMEM _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 PROGMEM _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 PROGMEM _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 PROGMEM _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 PROGMEM _MQ9[9] = {"LPG","-2.2535","2.9855","CH4","-1.6012","3.1476","CO","-1.749","2.827"};
const String PROGMEM _MQ131[9] = {"Nox","-2.7245","3.3004","CL2","-1.0333","1.7117","O3","-1.2037","1.6455"};
const String PROGMEM _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 PROGMEM _MQ303A[9] = {"Iso-butano","-2.3543","1.144","Hydrogeno","-2.4338","0.7558","Ethanol","-2.5597","0.4436"};
const String PROGMEM _MQ309A[12] = {"H2","-2.1311","3.0886","CH4","-1.6554","2.985","CO","-4.7623","6.7413","Alcohol","-3.7686","5.6744"};
class MQUnifiedsensor
{