From 9497574e11ec862176b50700e950b59f52ea4c11 Mon Sep 17 00:00:00 2001 From: miguel5612 Date: Mon, 30 Mar 2020 19:17:25 -0500 Subject: [PATCH] Fixed issue on calibratioN --- examples/Alcoholimeter/Alcoholimeter.ino | 27 ++++++++++++++---- examples/Calibration/Calibration.ino | 4 +++ examples/ESP8266/ESP8266.ino | 35 +++++++++++++++++------- examples/MQ-131/MQ-131.ino | 25 ++++++----------- examples/MQ-135-ALL/MQ-135-ALL.ino | 22 ++++++--------- examples/MQ-135/MQ-135.ino | 24 ++++++---------- examples/MQ-2/MQ-2.ino | 21 ++++++-------- examples/MQ-3/MQ-3.ino | 23 ++++++---------- examples/MQ-303A/MQ303.ino | 24 ++++++---------- examples/MQ-309A/MQ-309.ino | 24 ++++++---------- examples/MQ-4-ALL/MQ-4-ALL.ino | 21 ++++++-------- examples/MQ-4-LINEAR/MQ-4-LINEAR.ino | 22 ++++++--------- examples/MQ-4/MQ-4.ino | 24 ++++++---------- examples/MQ-5/MQ-5.ino | 24 ++++++---------- examples/MQ-6/MQ-6.ino | 23 ++++++---------- examples/MQ-7/MQ-7.ino | 24 ++++++---------- examples/MQ-8/MQ-8.ino | 23 ++++++---------- examples/MQ-9-ALL/MQ-9-ALL.ino | 21 ++++++-------- examples/MQ-9/MQ-9.ino | 24 ++++++---------- examples/MQ-Board/MQ-Board.ino | 22 --------------- examples/external_A2D/external_A2D.ino | 16 +++++------ examples/smokeDetector/smokeDetector.ino | 11 +++----- 22 files changed, 191 insertions(+), 293 deletions(-) diff --git a/examples/Alcoholimeter/Alcoholimeter.ino b/examples/Alcoholimeter/Alcoholimeter.ino index 37cfc1c..84f5048 100644 --- a/examples/Alcoholimeter/Alcoholimeter.ino +++ b/examples/Alcoholimeter/Alcoholimeter.ino @@ -54,18 +54,35 @@ void setup() { Hexane | 7585.3 | -2.849 */ - // Calibration setup - MQ3.setR0(3.86018237); - /* //If the RL value is different from 10K please assign your RL value with the following method: MQ3.setRL(10); */ - /***************************** MQ Init ********************************************/ //Remarks: Configure the pin of arduino as input. /************************************************************************************/ - MQ3.init(); + MQ3.init(); + /***************************** MQ CAlibration ********************************************/ + // Explanation: + // In this routine the sensor will measure the resistance of the sensor supposing before was pre-heated + // and now is on clean air (Calibration conditions), and it will setup R0 value. + // We recomend execute this routine only on setup or on the laboratory and save on the eeprom of your arduino + // This routine not need to execute to every restart, you can load your R0 if you know the value + // Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor + Serial.print("Calibrating please wait."); + float calcR0 = 0; + for(int i = 1; i<=10; i ++) + { + MQ3.update(); // Update data, the arduino will be read the voltage on the analog pin + calcR0 += MQ3.calibrate(RatioMQ3CleanAir); + Serial.print("."); + } + MQ3.setR0(calcR0/10); + Serial.println(" done!."); + + if(isinf(calcR0)) {Serial.println("Warning: Conection issue founded, R0 is infite (Open circuit detected) please check your wiring and supply"); while(1);} + if(calcR0 == 0){Serial.println("Warning: Conection issue founded, R0 is zero (Analog pin with short circuit to ground) please check your wiring and supply"); while(1);} + /***************************** MQ CAlibration ********************************************/ } void loop() { diff --git a/examples/Calibration/Calibration.ino b/examples/Calibration/Calibration.ino index 426bf66..43a5185 100644 --- a/examples/Calibration/Calibration.ino +++ b/examples/Calibration/Calibration.ino @@ -48,6 +48,10 @@ void setup() { Serial.begin(115200); MQ2.setRegressionMethod(1); //_PPM = a*ratio^b MQ2.setA(574.25); MQ2.setB(-2.222); // Configurate the ecuation values to get LPG concentration + /* + //If the RL value is different from 10K please assign your RL value with the following method: + MQ3.setRL(10); + */ //init the sensor MQ2.init(); //Print in serial monitor diff --git a/examples/ESP8266/ESP8266.ino b/examples/ESP8266/ESP8266.ino index fb51732..956185e 100644 --- a/examples/ESP8266/ESP8266.ino +++ b/examples/ESP8266/ESP8266.ino @@ -52,6 +52,10 @@ void setup() { Hexane | 7585.3 | -2.849 */ + /***************************** MQ Init ********************************************/ + //Remarks: Configure the pin of arduino as input. + /************************************************************************************/ + MQ3.init(); // Calibration setup MQ3.setR0(3.86018237); @@ -59,16 +63,27 @@ void setup() { //If the RL value is different from 10K please assign your RL value with the following method: MQ3.setRL(10); */ - - /***************************** MQ Init ********************************************/ - //Remarks: Configure the pin of arduino as input. - /************************************************************************************/ - MQ3.init(); - /***************************** MQ Init ********************************************/ - //Input: setup flag, if this function are on setup will print the headers (Optional - Default value: False) - //Output: print on serial port the information about sensor and sensor readings - //Remarks: Configure the pin of arduino as input. - /************************************************************************************/ + /***************************** MQ CAlibration ********************************************/ + // Explanation: + // In this routine the sensor will measure the resistance of the sensor supposing before was pre-heated + // and now is on clean air (Calibration conditions), and it will setup R0 value. + // We recomend execute this routine only on setup or on the laboratory and save on the eeprom of your arduino + // This routine not need to execute to every restart, you can load your R0 if you know the value + // Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor + Serial.print("Calibrating please wait."); + float calcR0 = 0; + for(int i = 1; i<=10; i ++) + { + MQ3.update(); // Update data, the arduino will be read the voltage on the analog pin + calcR0 += MQ3.calibrate(RatioMQ3CleanAir); + Serial.print("."); + } + MQ3.setR0(calcR0/10); + Serial.println(" done!."); + + if(isinf(calcR0)) {Serial.println("Warning: Conection issue founded, R0 is infite (Open circuit detected) please check your wiring and supply"); while(1);} + if(calcR0 == 0){Serial.println("Warning: Conection issue founded, R0 is zero (Analog pin with short circuit to ground) please check your wiring and supply"); while(1);} + /***************************** MQ CAlibration ********************************************/ MQ3.serialDebug(true); } diff --git a/examples/MQ-131/MQ-131.ino b/examples/MQ-131/MQ-131.ino index a381534..bfeaf54 100644 --- a/examples/MQ-131/MQ-131.ino +++ b/examples/MQ-131/MQ-131.ino @@ -52,7 +52,15 @@ void setup() { O3 | 23.943 | -1.11 */ - + + /***************************** MQ Init ********************************************/ + //Remarks: Configure the pin of arduino as input. + /************************************************************************************/ + MQ131.init(); + /* + //If the RL value is different from 10K please assign your RL value with the following method: + MQ131.setRL(10); + */ /***************************** MQ CAlibration ********************************************/ // Explanation: // In this routine the sensor will measure the resistance of the sensor supposing before was pre-heated @@ -74,21 +82,6 @@ void setup() { if(isinf(calcR0)) {Serial.println("Warning: Conection issue founded, R0 is infite (Open circuit detected) please check your wiring and supply"); while(1);} if(calcR0 == 0){Serial.println("Warning: Conection issue founded, R0 is zero (Analog pin with short circuit to ground) please check your wiring and supply"); while(1);} /***************************** MQ CAlibration ********************************************/ - - /* - //If the RL value is different from 10K please assign your RL value with the following method: - MQ131.setRL(10); - */ - - /***************************** MQ Init ********************************************/ - //Remarks: Configure the pin of arduino as input. - /************************************************************************************/ - MQ131.init(); - /***************************** MQ Init ********************************************/ - //Input: setup flag, if this function are on setup will print the headers (Optional - Default value: False) - //Output: print on serial port the information about sensor and sensor readings - //Remarks: Configure the pin of arduino as input. - /************************************************************************************/ MQ131.serialDebug(true); } diff --git a/examples/MQ-135-ALL/MQ-135-ALL.ino b/examples/MQ-135-ALL/MQ-135-ALL.ino index 224d468..3967e71 100644 --- a/examples/MQ-135-ALL/MQ-135-ALL.ino +++ b/examples/MQ-135-ALL/MQ-135-ALL.ino @@ -43,7 +43,14 @@ void setup() { //Set math model to calculate the PPM concentration and the value of constants MQ135.setRegressionMethod(1); //_PPM = a*ratio^b - + /***************************** MQ Init ********************************************/ + //Remarks: Configure the pin of arduino as input. + /************************************************************************************/ + MQ135.init(); + /* + //If the RL value is different from 10K please assign your RL value with the following method: + MQ135.setRL(10); + */ /***************************** MQ CAlibration ********************************************/ // Explanation: // In this routine the sensor will measure the resistance of the sensor supposing before was pre-heated @@ -65,19 +72,6 @@ void setup() { if(isinf(calcR0)) {Serial.println("Warning: Conection issue founded, R0 is infite (Open circuit detected) please check your wiring and supply"); while(1);} if(calcR0 == 0){Serial.println("Warning: Conection issue founded, R0 is zero (Analog pin with short circuit to ground) please check your wiring and supply"); while(1);} /***************************** MQ CAlibration ********************************************/ - - /* - //If the RL value is different from 10K please assign your RL value with the following method: - MQ135.setRL(10); - */ - - MQ135.init(); - /***************************** MQ Init ********************************************/ - //Input: setup flag, if this function are on setup will print the headers (Optional - Default value: False) - //Output: print on serial port the information about sensor and sensor readings - //Remarks: Configure the pin of arduino as input. - /************************************************************************************/ - Serial.println("** Lectures from MQ-135 ****"); Serial.println("| CO | Alcohol | CO2 | Tolueno | NH4 | Acteona |"); } diff --git a/examples/MQ-135/MQ-135.ino b/examples/MQ-135/MQ-135.ino index 6399054..8471e05 100644 --- a/examples/MQ-135/MQ-135.ino +++ b/examples/MQ-135/MQ-135.ino @@ -54,8 +54,15 @@ void setup() { NH4 | 102.2 | -2.473 Acetona | 34.668 | -3.369 */ - + /***************************** MQ Init ********************************************/ + //Remarks: Configure the pin of arduino as input. + /************************************************************************************/ + MQ135.init(); + /* + //If the RL value is different from 10K please assign your RL value with the following method: + MQ135.setRL(10); + */ /***************************** MQ CAlibration ********************************************/ // Explanation: // In this routine the sensor will measure the resistance of the sensor supposing before was pre-heated @@ -77,21 +84,6 @@ void setup() { if(isinf(calcR0)) {Serial.println("Warning: Conection issue founded, R0 is infite (Open circuit detected) please check your wiring and supply"); while(1);} if(calcR0 == 0){Serial.println("Warning: Conection issue founded, R0 is zero (Analog pin with short circuit to ground) please check your wiring and supply"); while(1);} /***************************** MQ CAlibration ********************************************/ - - /* - //If the RL value is different from 10K please assign your RL value with the following method: - MQ135.setRL(10); - */ - - /***************************** MQ Init ********************************************/ - //Remarks: Configure the pin of arduino as input. - /************************************************************************************/ - MQ135.init(); - /***************************** MQ Init ********************************************/ - //Input: setup flag, if this function are on setup will print the headers (Optional - Default value: False) - //Output: print on serial port the information about sensor and sensor readings - //Remarks: Configure the pin of arduino as input. - /************************************************************************************/ MQ135.serialDebug(true); } diff --git a/examples/MQ-2/MQ-2.ino b/examples/MQ-2/MQ-2.ino index 43dc052..45c9370 100644 --- a/examples/MQ-2/MQ-2.ino +++ b/examples/MQ-2/MQ-2.ino @@ -52,6 +52,14 @@ void setup() { Propane| 658.71 | -2.168 */ + /***************************** MQ Init ********************************************/ + //Remarks: Configure the pin of arduino as input. + /************************************************************************************/ + MQ2.init(); + /* + //If the RL value is different from 10K please assign your RL value with the following method: + MQ2.setRL(10); + */ /***************************** MQ CAlibration ********************************************/ // Explanation: // In this routine the sensor will measure the resistance of the sensor supposing before was pre-heated @@ -73,20 +81,7 @@ void setup() { if(isinf(calcR0)) {Serial.println("Warning: Conection issue founded, R0 is infite (Open circuit detected) please check your wiring and supply"); while(1);} if(calcR0 == 0){Serial.println("Warning: Conection issue founded, R0 is zero (Analog pin with short circuit to ground) please check your wiring and supply"); while(1);} /***************************** MQ CAlibration ********************************************/ - /* - //If the RL value is different from 10K please assign your RL value with the following method: - MQ2.setRL(10); - */ - /***************************** MQ Init ********************************************/ - //Remarks: Configure the pin of arduino as input. - /************************************************************************************/ - MQ2.init(); - /***************************** MQ Init ********************************************/ - //Input: setup flag, if this function are on setup will print the headers (Optional - Default value: False) - //Output: print on serial port the information about sensor and sensor readings - //Remarks: Configure the pin of arduino as input. - /************************************************************************************/ MQ2.serialDebug(true); } diff --git a/examples/MQ-3/MQ-3.ino b/examples/MQ-3/MQ-3.ino index 3c02dd1..1678463 100644 --- a/examples/MQ-3/MQ-3.ino +++ b/examples/MQ-3/MQ-3.ino @@ -53,7 +53,15 @@ void setup() { Hexane | 7585.3 | -2.849 */ + /***************************** MQ Init ********************************************/ + //Remarks: Configure the pin of arduino as input. + /************************************************************************************/ + MQ3.init(); + /* + //If the RL value is different from 10K please assign your RL value with the following method: + MQ3.setRL(10); + */ /***************************** MQ CAlibration ********************************************/ // Explanation: // In this routine the sensor will measure the resistance of the sensor supposing before was pre-heated @@ -75,21 +83,6 @@ void setup() { if(isinf(calcR0)) {Serial.println("Warning: Conection issue founded, R0 is infite (Open circuit detected) please check your wiring and supply"); while(1);} if(calcR0 == 0){Serial.println("Warning: Conection issue founded, R0 is zero (Analog pin with short circuit to ground) please check your wiring and supply"); while(1);} /***************************** MQ CAlibration ********************************************/ - - /* - //If the RL value is different from 10K please assign your RL value with the following method: - MQ3.setRL(10); - */ - - /***************************** MQ Init ********************************************/ - //Remarks: Configure the pin of arduino as input. - /************************************************************************************/ - MQ3.init(); - /***************************** MQ Init ********************************************/ - //Input: setup flag, if this function are on setup will print the headers (Optional - Default value: False) - //Output: print on serial port the information about sensor and sensor readings - //Remarks: Configure the pin of arduino as input. - /************************************************************************************/ MQ3.serialDebug(true); } diff --git a/examples/MQ-303A/MQ303.ino b/examples/MQ-303A/MQ303.ino index 255f326..d98644b 100644 --- a/examples/MQ-303A/MQ303.ino +++ b/examples/MQ-303A/MQ303.ino @@ -52,7 +52,14 @@ void setup() { Ethanol | 3.4916 | -2.432 */ - + /***************************** MQ Init ********************************************/ + //Remarks: Configure the pin of arduino as input. + /************************************************************************************/ + MQ303.init(); + /* + //If the RL value is different from 10K please assign your RL value with the following method: + MQ303.setRL(10); + */ /***************************** MQ CAlibration ********************************************/ // Explanation: // In this routine the sensor will measure the resistance of the sensor supposing before was pre-heated @@ -74,21 +81,6 @@ void setup() { if(isinf(calcR0)) {Serial.println("Warning: Conection issue founded, R0 is infite (Open circuit detected) please check your wiring and supply"); while(1);} if(calcR0 == 0){Serial.println("Warning: Conection issue founded, R0 is zero (Analog pin with short circuit to ground) please check your wiring and supply"); while(1);} /***************************** MQ CAlibration ********************************************/ - - /* - //If the RL value is different from 10K please assign your RL value with the following method: - MQ303.setRL(10); - */ - - /***************************** MQ Init ********************************************/ - //Remarks: Configure the pin of arduino as input. - /************************************************************************************/ - MQ303.init(); - /***************************** MQ Init ********************************************/ - //Input: setup flag, if this function are on setup will print the headers (Optional - Default value: False) - //Output: print on serial port the information about sensor and sensor readings - //Remarks: Configure the pin of arduino as input. - /************************************************************************************/ MQ303.serialDebug(true); } diff --git a/examples/MQ-309A/MQ-309.ino b/examples/MQ-309A/MQ-309.ino index bdf847f..75318b6 100644 --- a/examples/MQ-309A/MQ-309.ino +++ b/examples/MQ-309A/MQ-309.ino @@ -53,7 +53,14 @@ void setup() { ALCOHOL | 473622 | -3.647 */ - + /***************************** MQ Init ********************************************/ + //Remarks: Configure the pin of arduino as input. + /************************************************************************************/ + MQ309.init(); + /* + //If the RL value is different from 10K please assign your RL value with the following method: + MQ309.setRL(10); + */ /***************************** MQ CAlibration ********************************************/ // Explanation: // In this routine the sensor will measure the resistance of the sensor supposing before was pre-heated @@ -75,21 +82,6 @@ void setup() { if(isinf(calcR0)) {Serial.println("Warning: Conection issue founded, R0 is infite (Open circuit detected) please check your wiring and supply"); while(1);} if(calcR0 == 0){Serial.println("Warning: Conection issue founded, R0 is zero (Analog pin with short circuit to ground) please check your wiring and supply"); while(1);} /***************************** MQ CAlibration ********************************************/ - - /* - //If the RL value is different from 10K please assign your RL value with the following method: - MQ309.setRL(10); - */ - - /***************************** MQ Init ********************************************/ - //Remarks: Configure the pin of arduino as input. - /************************************************************************************/ - MQ309.init(); - /***************************** MQ Init ********************************************/ - //Input: setup flag, if this function are on setup will print the headers (Optional - Default value: False) - //Output: print on serial port the information about sensor and sensor readings - //Remarks: Configure the pin of arduino as input. - /************************************************************************************/ MQ309.serialDebug(true); } diff --git a/examples/MQ-4-ALL/MQ-4-ALL.ino b/examples/MQ-4-ALL/MQ-4-ALL.ino index f42fb13..fc6a408 100644 --- a/examples/MQ-4-ALL/MQ-4-ALL.ino +++ b/examples/MQ-4-ALL/MQ-4-ALL.ino @@ -43,7 +43,14 @@ void setup() { MQ4.setRegressionMethod(1); //_PPM = a*ratio^b - + /***************************** MQ Init ********************************************/ + //Remarks: Configure the pin of arduino as input. + /************************************************************************************/ + MQ4.init(); + /* + //If the RL value is different from 10K please assign your RL value with the following method: + MQ4.setRL(10); + */ /***************************** MQ CAlibration ********************************************/ // Explanation: // In this routine the sensor will measure the resistance of the sensor supposing before was pre-heated @@ -66,18 +73,6 @@ void setup() { if(calcR0 == 0){Serial.println("Warning: Conection issue founded, R0 is zero (Analog pin with short circuit to ground) please check your wiring and supply"); while(1);} /***************************** MQ CAlibration ********************************************/ - /* - //If the RL value is different from 10K please assign your RL value with the following method: - MQ4.setRL(10); - */ - - /***************************** MQ Init ********************************************/ - //Input: setup flag, if this function are on setup will print the headers (Optional - Default value: False) - //Output: print on serial port the information about sensor and sensor readings - //Remarks: Configure the pin of arduino as input. - /************************************************************************************/ - MQ4.init(); - Serial.println("*************** Lectures from MQ-4 **********************"); Serial.println("| LPG | CH4 | CO | Alcohol | Smoke |"); } diff --git a/examples/MQ-4-LINEAR/MQ-4-LINEAR.ino b/examples/MQ-4-LINEAR/MQ-4-LINEAR.ino index cee7235..3594f86 100644 --- a/examples/MQ-4-LINEAR/MQ-4-LINEAR.ino +++ b/examples/MQ-4-LINEAR/MQ-4-LINEAR.ino @@ -42,8 +42,14 @@ void setup() { //Set math model to calculate the PPM concentration and the value of constants MQ4.setRegressionMethod(0); //_PPM = pow(10, (log10(ratio)-b)/a) - - + /***************************** MQ Init ********************************************/ + //Remarks: Configure the pin of arduino as input. + /************************************************************************************/ + MQ4.init(); + /* + //If the RL value is different from 10K please assign your RL value with the following method: + MQ4.setRL(10); + */ /***************************** MQ CAlibration ********************************************/ // Explanation: // In this routine the sensor will measure the resistance of the sensor supposing before was pre-heated @@ -66,18 +72,6 @@ void setup() { if(calcR0 == 0){Serial.println("Warning: Conection issue founded, R0 is zero (Analog pin with short circuit to ground) please check your wiring and supply"); while(1);} /***************************** MQ CAlibration ********************************************/ - /* - //If the RL value is different from 10K please assign your RL value with the following method: - MQ4.setRL(10); - */ - - /***************************** MQ Init ********************************************/ - //Input: setup flag, if this function are on setup will print the headers (Optional - Default value: False) - //Output: print on serial port the information about sensor and sensor readings - //Remarks: Configure the pin of arduino as input. - /************************************************************************************/ - MQ4.init(); - Serial.println("** Lectures from MQ-4**********"); Serial.println("| LPG |"); } diff --git a/examples/MQ-4/MQ-4.ino b/examples/MQ-4/MQ-4.ino index 88ba024..b90b506 100644 --- a/examples/MQ-4/MQ-4.ino +++ b/examples/MQ-4/MQ-4.ino @@ -53,7 +53,14 @@ void setup() { */ - + /***************************** MQ Init ********************************************/ + //Remarks: Configure the pin of arduino as input. + /************************************************************************************/ + MQ4.init(); + /* + //If the RL value is different from 10K please assign your RL value with the following method: + MQ4.setRL(10); + */ /***************************** MQ CAlibration ********************************************/ // Explanation: // In this routine the sensor will measure the resistance of the sensor supposing before was pre-heated @@ -75,21 +82,6 @@ void setup() { if(isinf(calcR0)) {Serial.println("Warning: Conection issue founded, R0 is infite (Open circuit detected) please check your wiring and supply"); while(1);} if(calcR0 == 0){Serial.println("Warning: Conection issue founded, R0 is zero (Analog pin with short circuit to ground) please check your wiring and supply"); while(1);} /***************************** MQ CAlibration ********************************************/ - - /* - //If the RL value is different from 10K please assign your RL value with the following method: - MQ4.setRL(10); - */ - - /***************************** MQ Init ********************************************/ - //Remarks: Configure the pin of arduino as input. - /************************************************************************************/ - MQ4.init(); - /***************************** MQ Init ********************************************/ - //Input: setup flag, if this function are on setup will print the headers (Optional - Default value: False) - //Output: print on serial port the information about sensor and sensor readings - //Remarks: Configure the pin of arduino as input. - /************************************************************************************/ MQ4.serialDebug(true); } diff --git a/examples/MQ-5/MQ-5.ino b/examples/MQ-5/MQ-5.ino index 83a0e1b..4f99b42 100644 --- a/examples/MQ-5/MQ-5.ino +++ b/examples/MQ-5/MQ-5.ino @@ -53,7 +53,14 @@ void setup() { Alcohol| 97124 | -4.918 */ - + /***************************** MQ Init ********************************************/ + //Remarks: Configure the pin of arduino as input. + /************************************************************************************/ + MQ5.init(); + /* + //If the RL value is different from 10K please assign your RL value with the following method: + MQ5.setRL(10); + */ /***************************** MQ CAlibration ********************************************/ // Explanation: // In this routine the sensor will measure the resistance of the sensor supposing before was pre-heated @@ -75,21 +82,6 @@ void setup() { if(isinf(calcR0)) {Serial.println("Warning: Conection issue founded, R0 is infite (Open circuit detected) please check your wiring and supply"); while(1);} if(calcR0 == 0){Serial.println("Warning: Conection issue founded, R0 is zero (Analog pin with short circuit to ground) please check your wiring and supply"); while(1);} /***************************** MQ CAlibration ********************************************/ - - /* - //If the RL value is different from 10K please assign your RL value with the following method: - MQ5.setRL(10); - */ - - /***************************** MQ Init ********************************************/ - //Remarks: Configure the pin of arduino as input. - /************************************************************************************/ - MQ5.init(); - /***************************** MQ Init ********************************************/ - //Input: setup flag, if this function are on setup will print the headers (Optional - Default value: False) - //Output: print on serial port the information about sensor and sensor readings - //Remarks: Configure the pin of arduino as input. - /************************************************************************************/ MQ5.serialDebug(true); } diff --git a/examples/MQ-6/MQ-6.ino b/examples/MQ-6/MQ-6.ino index fde8ec8..d9a6353 100644 --- a/examples/MQ-6/MQ-6.ino +++ b/examples/MQ-6/MQ-6.ino @@ -53,7 +53,14 @@ void setup() { Alcohol | 50000000 | -6.017 */ - + /***************************** MQ Init ********************************************/ + //Remarks: Configure the pin of arduino as input. + /************************************************************************************/ + MQ6.init(); + /* + //If the RL value is different from 10K please assign your RL value with the following method: + MQ6.setRL(10); + */ /***************************** MQ CAlibration ********************************************/ // Explanation: // In this routine the sensor will measure the resistance of the sensor supposing before was pre-heated @@ -75,20 +82,6 @@ void setup() { if(isinf(calcR0)) {Serial.println("Warning: Conection issue founded, R0 is infite (Open circuit detected) please check your wiring and supply"); while(1);} if(calcR0 == 0){Serial.println("Warning: Conection issue founded, R0 is zero (Analog pin with short circuit to ground) please check your wiring and supply"); while(1);} /***************************** MQ CAlibration ********************************************/ - /* - //If the RL value is different from 10K please assign your RL value with the following method: - MQ6.setRL(10); - */ - - /***************************** MQ Init ********************************************/ - //Remarks: Configure the pin of arduino as input. - /************************************************************************************/ - MQ6.init(); - /***************************** MQ Init ********************************************/ - //Input: setup flag, if this function are on setup will print the headers (Optional - Default value: False) - //Output: print on serial port the information about sensor and sensor readings - //Remarks: Configure the pin of arduino as input. - /************************************************************************************/ MQ6.serialDebug(true); } diff --git a/examples/MQ-7/MQ-7.ino b/examples/MQ-7/MQ-7.ino index e374c88..f9c82ee 100644 --- a/examples/MQ-7/MQ-7.ino +++ b/examples/MQ-7/MQ-7.ino @@ -54,7 +54,14 @@ void setup() { Alcohol | 40000000000000000 | -12.35 */ - + /***************************** MQ Init ********************************************/ + //Remarks: Configure the pin of arduino as input. + /************************************************************************************/ + MQ7.init(); + /* + //If the RL value is different from 10K please assign your RL value with the following method: + MQ7.setRL(10); + */ /***************************** MQ CAlibration ********************************************/ // Explanation: // In this routine the sensor will measure the resistance of the sensor supposing before was pre-heated @@ -76,21 +83,6 @@ void setup() { if(isinf(calcR0)) {Serial.println("Warning: Conection issue founded, R0 is infite (Open circuit detected) please check your wiring and supply"); while(1);} if(calcR0 == 0){Serial.println("Warning: Conection issue founded, R0 is zero (Analog pin with short circuit to ground) please check your wiring and supply"); while(1);} /***************************** MQ CAlibration ********************************************/ - - /* - //If the RL value is different from 10K please assign your RL value with the following method: - MQ7.setRL(10); - */ - - /***************************** MQ Init ********************************************/ - //Remarks: Configure the pin of arduino as input. - /************************************************************************************/ - MQ7.init(); - /***************************** MQ Init ********************************************/ - //Input: setup flag, if this function are on setup will print the headers (Optional - Default value: False) - //Output: print on serial port the information about sensor and sensor readings - //Remarks: Configure the pin of arduino as input. - /************************************************************************************/ MQ7.serialDebug(true); } diff --git a/examples/MQ-8/MQ-8.ino b/examples/MQ-8/MQ-8.ino index 6c6afab..66947db 100644 --- a/examples/MQ-8/MQ-8.ino +++ b/examples/MQ-8/MQ-8.ino @@ -54,7 +54,14 @@ void setup() { Alcohol | 76101 | -1.86 */ - + /***************************** MQ Init ********************************************/ + //Remarks: Configure the pin of arduino as input. + /************************************************************************************/ + MQ8.init(); + /* + //If the RL value is different from 10K please assign your RL value with the following method: + MQ8.setRL(10); + */ /***************************** MQ CAlibration ********************************************/ // Explanation: // In this routine the sensor will measure the resistance of the sensor supposing before was pre-heated @@ -76,20 +83,6 @@ void setup() { if(isinf(calcR0)) {Serial.println("Warning: Conection issue founded, R0 is infite (Open circuit detected) please check your wiring and supply"); while(1);} if(calcR0 == 0){Serial.println("Warning: Conection issue founded, R0 is zero (Analog pin with short circuit to ground) please check your wiring and supply"); while(1);} /***************************** MQ CAlibration ********************************************/ - /* - //If the RL value is different from 10K please assign your RL value with the following method: - MQ8.setRL(10); - */ - - /***************************** MQ Init ********************************************/ - //Remarks: Configure the pin of arduino as input. - /************************************************************************************/ - MQ8.init(); - /***************************** MQ Init ********************************************/ - //Input: setup flag, if this function are on setup will print the headers (Optional - Default value: False) - //Output: print on serial port the information about sensor and sensor readings - //Remarks: Configure the pin of arduino as input. - /************************************************************************************/ MQ8.serialDebug(true); } diff --git a/examples/MQ-9-ALL/MQ-9-ALL.ino b/examples/MQ-9-ALL/MQ-9-ALL.ino index b476f29..9479170 100644 --- a/examples/MQ-9-ALL/MQ-9-ALL.ino +++ b/examples/MQ-9-ALL/MQ-9-ALL.ino @@ -43,6 +43,14 @@ void setup() { MQ9.setRegressionMethod(1); //_PPM = a*ratio^b + /***************************** MQ Init ********************************************/ + //Remarks: Configure the pin of arduino as input. + /************************************************************************************/ + MQ9.init(); + /* + //If the RL value is different from 10K please assign your RL value with the following method: + MQ9.setRL(10); + */ /***************************** MQ CAlibration ********************************************/ // Explanation: // In this routine the sensor will measure the resistance of the sensor supposing before was pre-heated @@ -64,19 +72,6 @@ void setup() { if(isinf(calcR0)) {Serial.println("Warning: Conection issue founded, R0 is infite (Open circuit detected) please check your wiring and supply"); while(1);} if(calcR0 == 0){Serial.println("Warning: Conection issue founded, R0 is zero (Analog pin with short circuit to ground) please check your wiring and supply"); while(1);} /***************************** MQ CAlibration ********************************************/ - - /* - //If the RL value is different from 10K please assign your RL value with the following method: - MQ9.setRL(10); - */ - - /***************************** MQ Init ********************************************/ - //Input: setup flag, if this function are on setup will print the headers (Optional - Default value: False) - //Output: print on serial port the information about sensor and sensor readings - //Remarks: Configure the pin of arduino as input. - /************************************************************************************/ - MQ9.init(); - Serial.println("** Lectures from MQ-9 ****"); Serial.println("| LPG | CH4 | CO |"); } diff --git a/examples/MQ-9/MQ-9.ino b/examples/MQ-9/MQ-9.ino index 0f44bd8..d269969 100644 --- a/examples/MQ-9/MQ-9.ino +++ b/examples/MQ-9/MQ-9.ino @@ -50,8 +50,15 @@ void setup() { CH4 | 4269.6 | -2.648 CO | 599.65 | -2.244 */ - + /***************************** MQ Init ********************************************/ + //Remarks: Configure the pin of arduino as input. + /************************************************************************************/ + MQ9.init(); + /* + //If the RL value is different from 10K please assign your RL value with the following method: + MQ9.setRL(10); + */ /***************************** MQ CAlibration ********************************************/ // Explanation: // In this routine the sensor will measure the resistance of the sensor supposing before was pre-heated @@ -73,21 +80,6 @@ void setup() { if(isinf(calcR0)) {Serial.println("Warning: Conection issue founded, R0 is infite (Open circuit detected) please check your wiring and supply"); while(1);} if(calcR0 == 0){Serial.println("Warning: Conection issue founded, R0 is zero (Analog pin with short circuit to ground) please check your wiring and supply"); while(1);} /***************************** MQ CAlibration ********************************************/ - - /* - //If the RL value is different from 10K please assign your RL value with the following method: - MQ9.setRL(10); - */ - - /***************************** MQ Init ********************************************/ - //Remarks: Configure the pin of arduino as input. - /************************************************************************************/ - MQ9.init(); - /***************************** MQ Init ********************************************/ - //Input: setup flag, if this function are on setup will print the headers (Optional - Default value: False) - //Output: print on serial port the information about sensor and sensor readings - //Remarks: Configure the pin of arduino as input. - /************************************************************************************/ MQ9.serialDebug(true); } diff --git a/examples/MQ-Board/MQ-Board.ino b/examples/MQ-Board/MQ-Board.ino index ec6ede8..dd32ce2 100644 --- a/examples/MQ-Board/MQ-Board.ino +++ b/examples/MQ-Board/MQ-Board.ino @@ -177,28 +177,6 @@ void loop() { MQ7.update(); MQ8.update(); MQ9.update(); - /* - //Rutina de calibracion - Uncomment if you need (setup too and header) - if(calibration_button) - { - float R0 = MQ2.calibrate(); - MQ2.setR0(R0): - R0 = MQ3.calibrate(); - MQ3.setR0(R0): - R0 = MQ4.calibrate(); - MQ4.setR0(R0): - R0 = MQ5.calibrate(); - MQ5.setR0(R0): - R0 = MQ6.calibrate(); - MQ6.setR0(R0): - R0 = MQ7.calibrate(); - MQ7.setR0(R0): - R0 = MQ8.calibrate(); - MQ8.setR0(R0): - R0 = MQ9.calibrate(); - MQ9.setR0(R0): - } - */ //Read the sensor and print in serial port float MQ2Lecture = MQ2.readSensor(); float MQ3Lecture = MQ3.readSensor(); diff --git a/examples/external_A2D/external_A2D.ino b/examples/external_A2D/external_A2D.ino index 61d479a..03eba86 100644 --- a/examples/external_A2D/external_A2D.ino +++ b/examples/external_A2D/external_A2D.ino @@ -18,6 +18,8 @@ Please take care, arduino A0 pin represent the analog input configured on #define pin - For this example this doesn't matter You will connect your sensor to your external A2D Sensor + This example code is in the public domain. + Important: 1. Although it doesn't matter what pin you put in when initializing your MQ sensor function it is important that you don't for any reason invoke the MQ.init() method because that method configures the selected pin as input and you may need it for @@ -27,10 +29,6 @@ 3. You must ensure that when invoking the setADC(value) method the value you are passing is within the expected parameters, for example if it is a 10-bit ADC converter, we expect a value between 0 and 2^10 = 1024 - - - This example code is in the public domain. - */ //Include the library @@ -67,6 +65,11 @@ void setup() { */ + /* + //If the RL value is different from 10K please assign your RL value with the following method: + MQ3.setRL(10); + */ + /***************************** MQ CAlibration ********************************************/ // Explanation: // In this routine the sensor will measure the resistance of the sensor supposing before was pre-heated @@ -90,11 +93,6 @@ void setup() { if(calcR0 == 0){Serial.println("Warning: Conection issue founded, R0 is zero (Analog pin with short circuit to ground) please check your wiring and supply"); while(1);} /***************************** MQ CAlibration ********************************************/ - /* - //If the RL value is different from 10K please assign your RL value with the following method: - MQ3.setRL(10); - */ - MQ3.serialDebug(true); } diff --git a/examples/smokeDetector/smokeDetector.ino b/examples/smokeDetector/smokeDetector.ino index ae89ee0..973cc5a 100644 --- a/examples/smokeDetector/smokeDetector.ino +++ b/examples/smokeDetector/smokeDetector.ino @@ -51,7 +51,10 @@ void setup() { //Remarks: Configure the pin of arduino as input. /************************************************************************************/ MQ4.init(); - + /* + //If the RL value is different from 10K please assign your RL value with the following method: + MQ4.setRL(10); + */ /***************************** MQ CAlibration ********************************************/ // Explanation: // In this routine the sensor will measure the resistance of the sensor supposing before was pre-heated @@ -73,12 +76,6 @@ void setup() { if(isinf(calcR0)) {Serial.println("Warning: Conection issue founded, R0 is infite (Open circuit detected) please check your wiring and supply"); while(1);} if(calcR0 == 0){Serial.println("Warning: Conection issue founded, R0 is zero (Analog pin with short circuit to ground) please check your wiring and supply"); while(1);} /***************************** MQ CAlibration ********************************************/ - - - /* - //If the RL value is different from 10K please assign your RL value with the following method: - MQ4.setRL(10); - */ MQ4.serialDebug(true); }