mirror of
https://github.com/miguel5612/MQSensorsLib.git
synced 2025-03-15 05:17:30 +03:00
Updated and fixed typo examples
This commit is contained in:
parent
990e6878ef
commit
07b6948f76
@ -50,7 +50,7 @@ We present a unified library for MQ sensors, this library allows to read MQ sign
|
|||||||
MQUnifiedsensor MQ4(Board, Voltage_Resolution, ADC_Bit_Resolution, Pin, Type);
|
MQUnifiedsensor MQ4(Board, Voltage_Resolution, ADC_Bit_Resolution, Pin, Type);
|
||||||
// Setup
|
// Setup
|
||||||
MQ4.setRegressionMethod("Exponential"); //_PPM = a*ratio^b
|
MQ4.setRegressionMethod("Exponential"); //_PPM = a*ratio^b
|
||||||
MQ4.setA(1012.7); MQ4.setB(-2.786); // Configurate the ecuation values to get CH4 concentration
|
MQ4.setA(1012.7); MQ4.setB(-2.786); // Configure the equation to to calculate CH4 concentration
|
||||||
MQ4.setR0(3.86018237); // Value getted on calibration
|
MQ4.setR0(3.86018237); // Value getted on calibration
|
||||||
// Loop
|
// Loop
|
||||||
MQ4.init();
|
MQ4.init();
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
Wiring:
|
Wiring:
|
||||||
https://github.com/miguel5612/MQSensorsLib_Docs/blob/master/static/img/MQ_Arduino.PNG
|
https://github.com/miguel5612/MQSensorsLib_Docs/blob/master/static/img/MQ_Arduino.PNG
|
||||||
Please take care, arduino A0 pin represent the analog input configured on #define pin
|
Please make sure arduino A0 pin represents the analog input configured on #define pin
|
||||||
|
|
||||||
This example code is in the public domain.
|
This example code is in the public domain.
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ void setup() {
|
|||||||
|
|
||||||
//Set math model to calculate the PPM concentration and the value of constants
|
//Set math model to calculate the PPM concentration and the value of constants
|
||||||
MQ3.setRegressionMethod(1); //_PPM = a*ratio^b
|
MQ3.setRegressionMethod(1); //_PPM = a*ratio^b
|
||||||
MQ3.setA(0.3934); MQ3.setB(-1.504); // Configurate the ecuation values to get Alcohol concentration
|
MQ3.setA(0.3934); MQ3.setB(-1.504); //Configure the equation to calculate Alcohol concentration value
|
||||||
/*
|
/*
|
||||||
Exponential regression:
|
Exponential regression:
|
||||||
Gas | a | b
|
Gas | a | b
|
||||||
@ -64,30 +64,30 @@ void setup() {
|
|||||||
MQ3.init();
|
MQ3.init();
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
// Explanation:
|
// Explanation:
|
||||||
// In this routine the sensor will measure the resistance of the sensor supposing before was pre-heated
|
// In this routine the sensor will measure the resistance of the sensor supposedly before being pre-heated
|
||||||
// and now is on clean air (Calibration conditions), and it will setup R0 value.
|
// and on clean air (Calibration conditions), setting up R0 value.
|
||||||
// We recomend execute this routine only on setup or on the laboratory and save on the eeprom of your arduino
|
// We recomend executing this routine only on setup in laboratory conditions.
|
||||||
// This routine not need to execute to every restart, you can load your R0 if you know the value
|
// This routine does not need to be executed on each restart, you can load your R0 value from eeprom.
|
||||||
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
||||||
Serial.print("Calibrating please wait.");
|
Serial.print("Calibrating please wait.");
|
||||||
float calcR0 = 0;
|
float calcR0 = 0;
|
||||||
for(int i = 1; i<=10; i ++)
|
for(int i = 1; i<=10; i ++)
|
||||||
{
|
{
|
||||||
MQ3.update(); // Update data, the arduino will be read the voltage on the analog pin
|
MQ3.update(); // Update data, the arduino will read the voltage from the analog pin
|
||||||
calcR0 += MQ3.calibrate(RatioMQ3CleanAir);
|
calcR0 += MQ3.calibrate(RatioMQ3CleanAir);
|
||||||
Serial.print(".");
|
Serial.print(".");
|
||||||
}
|
}
|
||||||
MQ3.setR0(calcR0/10);
|
MQ3.setR0(calcR0/10);
|
||||||
Serial.println(" done!.");
|
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(isinf(calcR0)) {Serial.println("Warning: Conection issue, R0 is infinite (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);}
|
if(calcR0 == 0){Serial.println("Warning: Conection issue found, R0 is zero (Analog pin shorts to ground) please check your wiring and supply"); while(1);}
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
MQ3.update(); // Update data, the arduino will be read the voltage on the analog pin
|
MQ3.update(); // Update data, the arduino will read the voltage from the analog pin
|
||||||
alcoholPPM = MQ3.readSensor(); // Sensor will read PPM concentration using the model and a and b values setted before or in the setup
|
alcoholPPM = MQ3.readSensor(); // Sensor will read PPM concentration using the model, a and b values set previously or from the setup
|
||||||
Serial.print("Alcohol now (PPM): ");
|
Serial.print("Alcohol now (PPM): ");
|
||||||
Serial.println(alcoholPPM);
|
Serial.println(alcoholPPM);
|
||||||
delay(500); //Sampling frequency
|
delay(500); //Sampling frequency
|
||||||
|
@ -47,7 +47,7 @@ void setup() {
|
|||||||
//Init serial port
|
//Init serial port
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
MQ2.setRegressionMethod(1); //_PPM = a*ratio^b
|
MQ2.setRegressionMethod(1); //_PPM = a*ratio^b
|
||||||
MQ2.setA(574.25); MQ2.setB(-2.222); // Configurate the ecuation values to get LPG concentration
|
MQ2.setA(574.25); MQ2.setB(-2.222); // Configure the equation to to calculate LPG concentration
|
||||||
/*
|
/*
|
||||||
//If the RL value is different from 10K please assign your RL value with the following method:
|
//If the RL value is different from 10K please assign your RL value with the following method:
|
||||||
MQ3.setRL(10);
|
MQ3.setRL(10);
|
||||||
|
@ -61,7 +61,7 @@ void setup()
|
|||||||
|
|
||||||
//Set math model to calculate the PPM concentration and the value of constants
|
//Set math model to calculate the PPM concentration and the value of constants
|
||||||
MQ2.setRegressionMethod(1); //_PPM = a*ratio^b
|
MQ2.setRegressionMethod(1); //_PPM = a*ratio^b
|
||||||
MQ2.setA(987.99); MQ2.setB(-2.162); // Configurate the ecuation values to get H2 concentration
|
MQ2.setA(987.99); MQ2.setB(-2.162); // Configure the equation to to calculate H2 concentration
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Exponential regression:
|
Exponential regression:
|
||||||
@ -84,24 +84,24 @@ void setup()
|
|||||||
*/
|
*/
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
// Explanation:
|
// Explanation:
|
||||||
// In this routine the sensor will measure the resistance of the sensor supposing before was pre-heated
|
// In this routine the sensor will measure the resistance of the sensor supposedly before being pre-heated
|
||||||
// and now is on clean air (Calibration conditions), and it will setup R0 value.
|
// and on clean air (Calibration conditions), setting up R0 value.
|
||||||
// We recomend execute this routine only on setup or on the laboratory and save on the eeprom of your arduino
|
// We recomend executing this routine only on setup in laboratory conditions.
|
||||||
// This routine not need to execute to every restart, you can load your R0 if you know the value
|
// This routine does not need to be executed on each restart, you can load your R0 value from eeprom.
|
||||||
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
||||||
Serial.print("Calibrating please wait.");
|
Serial.print("Calibrating please wait.");
|
||||||
float calcR0 = 0;
|
float calcR0 = 0;
|
||||||
for(int i = 1; i<=10; i ++)
|
for(int i = 1; i<=10; i ++)
|
||||||
{
|
{
|
||||||
MQ2.update(); // Update data, the arduino will be read the voltage on the analog pin
|
MQ2.update(); // Update data, the arduino will read the voltage from the analog pin
|
||||||
calcR0 += MQ2.calibrate(RatioMQ2CleanAir);
|
calcR0 += MQ2.calibrate(RatioMQ2CleanAir);
|
||||||
Serial.print(".");
|
Serial.print(".");
|
||||||
}
|
}
|
||||||
MQ2.setR0(calcR0/10);
|
MQ2.setR0(calcR0/10);
|
||||||
Serial.println(" done!.");
|
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(isinf(calcR0)) {Serial.println("Warning: Conection issue, R0 is infinite (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);}
|
if(calcR0 == 0){Serial.println("Warning: Conection issue found, R0 is zero (Analog pin shorts to ground) please check your wiring and supply"); while(1);}
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
//MQ2.serialDebug(true); uncomment if you want to print the table on the serial port
|
//MQ2.serialDebug(true); uncomment if you want to print the table on the serial port
|
||||||
|
|
||||||
@ -127,9 +127,9 @@ void setup()
|
|||||||
|
|
||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
MQ2.update(); // Update data, the arduino will be read the voltage on the analog pin
|
MQ2.update(); // Update data, the arduino will read the voltage from the analog pin
|
||||||
//MQ2.serialDebug(); // Will print the table on the serial port
|
//MQ2.serialDebug(); // Will print the table on the serial port
|
||||||
Serial.print(MQ2.readSensor()); // Sensor will read PPM concentration using the model and a and b values setted before or in the setup
|
Serial.print(MQ2.readSensor()); // Sensor will read PPM concentration using the model, a and b values set previously or from the setup
|
||||||
Serial.println(" PPM");
|
Serial.println(" PPM");
|
||||||
delay(500); //Sampling frequency
|
delay(500); //Sampling frequency
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ void setup() {
|
|||||||
|
|
||||||
//Set math model to calculate the PPM concentration and the value of constants
|
//Set math model to calculate the PPM concentration and the value of constants
|
||||||
MQ3.setRegressionMethod(1); //_PPM = a*ratio^b
|
MQ3.setRegressionMethod(1); //_PPM = a*ratio^b
|
||||||
MQ3.setA(4.8387); MQ3.setB(-2.68); // Configurate the ecuation values to get Benzene concentration
|
MQ3.setA(4.8387); MQ3.setB(-2.68); // Configure the equation to to calculate Benzene concentration
|
||||||
/*
|
/*
|
||||||
Exponential regression:
|
Exponential regression:
|
||||||
Gas | a | b
|
Gas | a | b
|
||||||
@ -63,31 +63,31 @@ void setup() {
|
|||||||
*/
|
*/
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
// Explanation:
|
// Explanation:
|
||||||
// In this routine the sensor will measure the resistance of the sensor supposing before was pre-heated
|
// In this routine the sensor will measure the resistance of the sensor supposedly before being pre-heated
|
||||||
// and now is on clean air (Calibration conditions), and it will setup R0 value.
|
// and on clean air (Calibration conditions), setting up R0 value.
|
||||||
// We recomend execute this routine only on setup or on the laboratory and save on the eeprom of your arduino
|
// We recomend executing this routine only on setup in laboratory conditions.
|
||||||
// This routine not need to execute to every restart, you can load your R0 if you know the value
|
// This routine does not need to be executed on each restart, you can load your R0 value from eeprom.
|
||||||
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
||||||
Serial.print("Calibrating please wait.");
|
Serial.print("Calibrating please wait.");
|
||||||
float calcR0 = 0;
|
float calcR0 = 0;
|
||||||
for(int i = 1; i<=10; i ++)
|
for(int i = 1; i<=10; i ++)
|
||||||
{
|
{
|
||||||
MQ3.update(); // Update data, the arduino will be read the voltage on the analog pin
|
MQ3.update(); // Update data, the arduino will read the voltage from the analog pin
|
||||||
calcR0 += MQ3.calibrate(RatioMQ3CleanAir);
|
calcR0 += MQ3.calibrate(RatioMQ3CleanAir);
|
||||||
Serial.print(".");
|
Serial.print(".");
|
||||||
}
|
}
|
||||||
MQ3.setR0(calcR0/10);
|
MQ3.setR0(calcR0/10);
|
||||||
Serial.println(" done!.");
|
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(isinf(calcR0)) {Serial.println("Warning: Conection issue, R0 is infinite (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);}
|
if(calcR0 == 0){Serial.println("Warning: Conection issue found, R0 is zero (Analog pin shorts to ground) please check your wiring and supply"); while(1);}
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
MQ3.serialDebug(true);
|
MQ3.serialDebug(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
MQ3.update(); // Update data, the arduino will be read the voltage on the analog pin
|
MQ3.update(); // Update data, the arduino will read the voltage from the analog pin
|
||||||
MQ3.readSensor(); // Sensor will read PPM concentration using the model and a and b values setted before or in the setup
|
MQ3.readSensor(); // Sensor will read PPM concentration using the model, a and b values set previously or from the setup
|
||||||
MQ3.serialDebug(); // Will print the table on the serial port
|
MQ3.serialDebug(); // Will print the table on the serial port
|
||||||
delay(500); //Sampling frequency
|
delay(500); //Sampling frequency
|
||||||
}
|
}
|
@ -40,7 +40,7 @@ void setup() {
|
|||||||
|
|
||||||
//Set math model to calculate the PPM concentration and the value of constants
|
//Set math model to calculate the PPM concentration and the value of constants
|
||||||
MQ3.setRegressionMethod(1); //_PPM = a*ratio^b
|
MQ3.setRegressionMethod(1); //_PPM = a*ratio^b
|
||||||
MQ3.setA(4.8387); MQ3.setB(-2.68); // Configurate the ecuation values to get Benzene concentration
|
MQ3.setA(4.8387); MQ3.setB(-2.68); // Configure the equation to to calculate Benzene concentration
|
||||||
/*
|
/*
|
||||||
Exponential regression:
|
Exponential regression:
|
||||||
Gas | a | b
|
Gas | a | b
|
||||||
@ -63,31 +63,31 @@ void setup() {
|
|||||||
*/
|
*/
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
// Explanation:
|
// Explanation:
|
||||||
// In this routine the sensor will measure the resistance of the sensor supposing before was pre-heated
|
// In this routine the sensor will measure the resistance of the sensor supposedly before being pre-heated
|
||||||
// and now is on clean air (Calibration conditions), and it will setup R0 value.
|
// and on clean air (Calibration conditions), setting up R0 value.
|
||||||
// We recomend execute this routine only on setup or on the laboratory and save on the eeprom of your arduino
|
// We recomend executing this routine only on setup in laboratory conditions.
|
||||||
// This routine not need to execute to every restart, you can load your R0 if you know the value
|
// This routine does not need to be executed on each restart, you can load your R0 value from eeprom.
|
||||||
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
||||||
Serial.print("Calibrating please wait.");
|
Serial.print("Calibrating please wait.");
|
||||||
float calcR0 = 0;
|
float calcR0 = 0;
|
||||||
for(int i = 1; i<=10; i ++)
|
for(int i = 1; i<=10; i ++)
|
||||||
{
|
{
|
||||||
MQ3.update(); // Update data, the arduino will be read the voltage on the analog pin
|
MQ3.update(); // Update data, the arduino will read the voltage from the analog pin
|
||||||
calcR0 += MQ3.calibrate(RatioMQ3CleanAir);
|
calcR0 += MQ3.calibrate(RatioMQ3CleanAir);
|
||||||
Serial.print(".");
|
Serial.print(".");
|
||||||
}
|
}
|
||||||
MQ3.setR0(calcR0/10);
|
MQ3.setR0(calcR0/10);
|
||||||
Serial.println(" done!.");
|
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(isinf(calcR0)) {Serial.println("Warning: Conection issue, R0 is infinite (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);}
|
if(calcR0 == 0){Serial.println("Warning: Conection issue found, R0 is zero (Analog pin shorts to ground) please check your wiring and supply"); while(1);}
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
MQ3.serialDebug(true);
|
MQ3.serialDebug(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
MQ3.update(); // Update data, the arduino will be read the voltage on the analog pin
|
MQ3.update(); // Update data, the arduino will read the voltage from the analog pin
|
||||||
MQ3.readSensor(); // Sensor will read PPM concentration using the model and a and b values setted before or in the setup
|
MQ3.readSensor(); // Sensor will read PPM concentration using the model, a and b values set previously or from the setup
|
||||||
MQ3.serialDebug(); // Will print the table on the serial port
|
MQ3.serialDebug(); // Will print the table on the serial port
|
||||||
delay(500); //Sampling frequency
|
delay(500); //Sampling frequency
|
||||||
}
|
}
|
@ -43,24 +43,24 @@ void setup() {
|
|||||||
|
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
// Explanation:
|
// Explanation:
|
||||||
// In this routine the sensor will measure the resistance of the sensor supposing before was pre-heated
|
// In this routine the sensor will measure the resistance of the sensor supposedly before being pre-heated
|
||||||
// and now is on clean air (Calibration conditions), and it will setup R0 value.
|
// and on clean air (Calibration conditions), setting up R0 value.
|
||||||
// We recomend execute this routine only on setup or on the laboratory and save on the eeprom of your arduino
|
// We recomend executing this routine only on setup in laboratory conditions.
|
||||||
// This routine not need to execute to every restart, you can load your R0 if you know the value
|
// This routine does not need to be executed on each restart, you can load your R0 value from eeprom.
|
||||||
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
||||||
Serial.print("Calibrating please wait.");
|
Serial.print("Calibrating please wait.");
|
||||||
float calcR0 = 0;
|
float calcR0 = 0;
|
||||||
for(int i = 1; i<=10; i ++)
|
for(int i = 1; i<=10; i ++)
|
||||||
{
|
{
|
||||||
MQ4.update(); // Update data, the arduino will be read the voltage on the analog pin
|
MQ4.update(); // Update data, the arduino will read the voltage from the analog pin
|
||||||
calcR0 += MQ4.calibrate(RatioMQ4CleanAir);
|
calcR0 += MQ4.calibrate(RatioMQ4CleanAir);
|
||||||
Serial.print(".");
|
Serial.print(".");
|
||||||
}
|
}
|
||||||
MQ4.setR0(calcR0/10);
|
MQ4.setR0(calcR0/10);
|
||||||
Serial.println(" done!.");
|
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(isinf(calcR0)) {Serial.println("Warning: Conection issue, R0 is infinite (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);}
|
if(calcR0 == 0){Serial.println("Warning: Conection issue found, R0 is zero (Analog pin shorts to ground) please check your wiring and supply"); while(1);}
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -75,23 +75,23 @@ void setup() {
|
|||||||
/************************************************************************************/
|
/************************************************************************************/
|
||||||
MQ4.init();
|
MQ4.init();
|
||||||
|
|
||||||
Serial.println("** Lectures from MQ-4**********");
|
Serial.println("** Values from MQ-4**********");
|
||||||
Serial.println("| LPG (Linear EQ) | LPG (Exponential EQ) |");
|
Serial.println("| LPG (Linear EQ) | LPG (Exponential EQ) |");
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
MQ4.update(); // Update data, the arduino will be read the voltage on the analog pin
|
MQ4.update(); // Update data, the arduino will read the voltage from the analog pin
|
||||||
|
|
||||||
//https://jayconsystems.com/blog/understanding-a-gas-sensor
|
//https://jayconsystems.com/blog/understanding-a-gas-sensor
|
||||||
//Set math model to calculate the PPM concentration and the value of constants
|
//Set math model to calculate the PPM concentration and the value of constants
|
||||||
MQ4.setRegressionMethod(0); //_PPM = pow(10, (log10(ratio)-b)/a)
|
MQ4.setRegressionMethod(0); //_PPM = pow(10, (log10(ratio)-b)/a)
|
||||||
MQ4.setA(-0.318); MQ4.setB(1.133); // A -> Slope, B -> Intersect with X - Axis
|
MQ4.setA(-0.318); MQ4.setB(1.133); // A -> Slope, B -> Intersect with X - Axis
|
||||||
float LPG1 = MQ4.readSensor(); // Sensor will read PPM concentration using the model and a and b values setted before or in the setup
|
float LPG1 = MQ4.readSensor(); // Sensor will read PPM concentration using the model, a and b values set previously or from the setup
|
||||||
|
|
||||||
//Set math model to calculate the PPM concentration and the value of constants
|
//Set math model to calculate the PPM concentration and the value of constants
|
||||||
MQ4.setRegressionMethod(1); //_PPM = a*ratio^b
|
MQ4.setRegressionMethod(1); //_PPM = a*ratio^b
|
||||||
MQ4.setA(1012.7); MQ4.setB(-2.786); // Configurate the ecuation values to get CH4 concentration
|
MQ4.setA(1012.7); MQ4.setB(-2.786); // Configure the equation to to calculate CH4 concentration
|
||||||
float LPG2 = MQ4.readSensor(); // Sensor will read PPM concentration using the model and a and b values setted before or in the setup
|
float LPG2 = MQ4.readSensor(); // Sensor will read PPM concentration using the model, a and b values set previously or from the setup
|
||||||
|
|
||||||
// exposure to 2000 ppm of LPG gas is immediately dangerous to life and health. In this section
|
// exposure to 2000 ppm of LPG gas is immediately dangerous to life and health. In this section
|
||||||
if(LPG1>=2000 || LPG2>=2000) Serial.println("Warning - Very high concentrations detected!");
|
if(LPG1>=2000 || LPG2>=2000) Serial.println("Warning - Very high concentrations detected!");
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
Wiring:
|
Wiring:
|
||||||
https://github.com/miguel5612/MQSensorsLib_Docs/blob/master/static/img/MQ_Arduino.PNG
|
https://github.com/miguel5612/MQSensorsLib_Docs/blob/master/static/img/MQ_Arduino.PNG
|
||||||
Please take care, arduino A0 pin represent the analog input configured on #define pin
|
Please make sure arduino A0 pin represents the analog input configured on #define pin
|
||||||
|
|
||||||
Note: high concentration MQ-131 sensor.
|
Note: high concentration MQ-131 sensor.
|
||||||
|
|
||||||
@ -44,7 +44,7 @@ void setup() {
|
|||||||
|
|
||||||
//Set math model to calculate the PPM concentration and the value of constants
|
//Set math model to calculate the PPM concentration and the value of constants
|
||||||
MQ131.setRegressionMethod(1); //_PPM = a*ratio^b
|
MQ131.setRegressionMethod(1); //_PPM = a*ratio^b
|
||||||
MQ131.setA(23.943); MQ131.setB(-1.11); // Configurate the ecuation values to get O3 concentration
|
MQ131.setA(23.943); MQ131.setB(-1.11); // Configure the equation to to calculate O3 concentration
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Exponential regression:
|
Exponential regression:
|
||||||
@ -65,32 +65,32 @@ void setup() {
|
|||||||
*/
|
*/
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
// Explanation:
|
// Explanation:
|
||||||
// In this routine the sensor will measure the resistance of the sensor supposing before was pre-heated
|
// In this routine the sensor will measure the resistance of the sensor supposedly before being pre-heated
|
||||||
// and now is on clean air (Calibration conditions), and it will setup R0 value.
|
// and on clean air (Calibration conditions), setting up R0 value.
|
||||||
// We recomend execute this routine only on setup or on the laboratory and save on the eeprom of your arduino
|
// We recomend executing this routine only on setup in laboratory conditions.
|
||||||
// This routine not need to execute to every restart, you can load your R0 if you know the value
|
// This routine does not need to be executed on each restart, you can load your R0 value from eeprom.
|
||||||
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
||||||
Serial.print("Calibrating please wait.");
|
Serial.print("Calibrating please wait.");
|
||||||
float calcR0 = 0;
|
float calcR0 = 0;
|
||||||
for(int i = 1; i<=10; i ++)
|
for(int i = 1; i<=10; i ++)
|
||||||
{
|
{
|
||||||
MQ131.update(); // Update data, the arduino will be read the voltage on the analog pin
|
MQ131.update(); // Update data, the arduino will read the voltage from the analog pin
|
||||||
calcR0 += MQ131.calibrate(RatioMQ131CleanAir);
|
calcR0 += MQ131.calibrate(RatioMQ131CleanAir);
|
||||||
Serial.print(".");
|
Serial.print(".");
|
||||||
}
|
}
|
||||||
MQ131.setR0(calcR0/10);
|
MQ131.setR0(calcR0/10);
|
||||||
Serial.println(" done!.");
|
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(isinf(calcR0)) {Serial.println("Warning: Conection issue, R0 is infinite (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);}
|
if(calcR0 == 0){Serial.println("Warning: Conection issue found, R0 is zero (Analog pin shorts to ground) please check your wiring and supply"); while(1);}
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
MQ131.serialDebug(true);
|
MQ131.serialDebug(true);
|
||||||
Serial.println("Ignore Ratio = RS/R0, for this example we will use readSensorR0Rs, the ratio calculated will be R0/Rs. Thanks :)");
|
Serial.println("Ignore Ratio = RS/R0, for this example we will use readSensorR0Rs, the ratio calculated will be R0/Rs. Thanks :)");
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
MQ131.update(); // Update data, the arduino will be read the voltage on the analog pin
|
MQ131.update(); // Update data, the arduino will read the voltage from the analog pin
|
||||||
MQ131.readSensorR0Rs(); // Sensor will read PPM concentration using the model and a and b values setted before or in the setup
|
MQ131.readSensorR0Rs(); // Sensor will read PPM concentration using the model, a and b values set previously or from the setup
|
||||||
MQ131.serialDebug(); // Will print the table on the serial port
|
MQ131.serialDebug(); // Will print the table on the serial port
|
||||||
delay(500); //Sampling frequency
|
delay(500); //Sampling frequency
|
||||||
}
|
}
|
@ -89,13 +89,13 @@ void loop() {
|
|||||||
float CO2 = MQ135.readSensor(); // Sensor will read PPM concentration using the model, a and b values set previously or from the setup
|
float CO2 = MQ135.readSensor(); // Sensor will read PPM concentration using the model, a and b values set previously or from the setup
|
||||||
|
|
||||||
MQ135.setA(44.947); MQ135.setB(-3.445); // Configure the equation to calculate Toluen concentration value
|
MQ135.setA(44.947); MQ135.setB(-3.445); // Configure the equation to calculate Toluen concentration value
|
||||||
float Tolueno = MQ135.readSensor(); // Sensor will read PPM concentration using the model, a and b values set previously or from the setup
|
float Toluen = MQ135.readSensor(); // Sensor will read PPM concentration using the model, a and b values set previously or from the setup
|
||||||
|
|
||||||
MQ135.setA(102.2 ); MQ135.setB(-2.473); // Configure the equation to calculate NH4 concentration value
|
MQ135.setA(102.2 ); MQ135.setB(-2.473); // Configure the equation to calculate NH4 concentration value
|
||||||
float NH4 = MQ135.readSensor(); // Sensor will read PPM concentration using the model, a and b values set previously or from the setup
|
float NH4 = MQ135.readSensor(); // Sensor will read PPM concentration using the model, a and b values set previously or from the setup
|
||||||
|
|
||||||
MQ135.setA(34.668); MQ135.setB(-3.369); // Configure the equation to calculate Aceton concentration value
|
MQ135.setA(34.668); MQ135.setB(-3.369); // Configure the equation to calculate Aceton concentration value
|
||||||
float Acetona = MQ135.readSensor(); // Sensor will read PPM concentration using the model, a and b values set previously or from the setup
|
float Aceton = MQ135.readSensor(); // Sensor will read PPM concentration using the model, a and b values set previously or from the setup
|
||||||
Serial.print("| "); Serial.print(CO);
|
Serial.print("| "); Serial.print(CO);
|
||||||
Serial.print(" | "); Serial.print(Alcohol);
|
Serial.print(" | "); Serial.print(Alcohol);
|
||||||
// Note: 200 Offset for CO2 source: https://github.com/miguel5612/MQSensorsLib/issues/29
|
// Note: 200 Offset for CO2 source: https://github.com/miguel5612/MQSensorsLib/issues/29
|
||||||
@ -106,9 +106,9 @@ void loop() {
|
|||||||
https://www.lavanguardia.com/natural/20190514/462242832581/concentracion-dioxido-cabono-co2-atmosfera-bate-record-historia-humanidad.html
|
https://www.lavanguardia.com/natural/20190514/462242832581/concentracion-dioxido-cabono-co2-atmosfera-bate-record-historia-humanidad.html
|
||||||
*/
|
*/
|
||||||
Serial.print(" | "); Serial.print(CO2 + 400);
|
Serial.print(" | "); Serial.print(CO2 + 400);
|
||||||
Serial.print(" | "); Serial.print(Tolueno);
|
Serial.print(" | "); Serial.print(Toluen);
|
||||||
Serial.print(" | "); Serial.print(NH4);
|
Serial.print(" | "); Serial.print(NH4);
|
||||||
Serial.print(" | "); Serial.print(Acetona);
|
Serial.print(" | "); Serial.print(Aceton);
|
||||||
Serial.println(" |");
|
Serial.println(" |");
|
||||||
/*
|
/*
|
||||||
Exponential regression:
|
Exponential regression:
|
||||||
@ -116,9 +116,9 @@ void loop() {
|
|||||||
CO | 605.18 | -3.937
|
CO | 605.18 | -3.937
|
||||||
Alcohol | 77.255 | -3.18
|
Alcohol | 77.255 | -3.18
|
||||||
CO2 | 110.47 | -2.862
|
CO2 | 110.47 | -2.862
|
||||||
Tolueno | 44.947 | -3.445
|
Toluen | 44.947 | -3.445
|
||||||
NH4 | 102.2 | -2.473
|
NH4 | 102.2 | -2.473
|
||||||
Acetona | 34.668 | -3.369
|
Aceton | 34.668 | -3.369
|
||||||
*/
|
*/
|
||||||
|
|
||||||
delay(500); //Sampling frequency
|
delay(500); //Sampling frequency
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
Wiring:
|
Wiring:
|
||||||
https://github.com/miguel5612/MQSensorsLib_Docs/blob/master/static/img/MQ_Arduino.PNG
|
https://github.com/miguel5612/MQSensorsLib_Docs/blob/master/static/img/MQ_Arduino.PNG
|
||||||
Please take care, arduino A0 pin represent the analog input configured on #define pin
|
Please make sure arduino A0 pin represents the analog input configured on #define pin
|
||||||
|
|
||||||
This example code is in the public domain.
|
This example code is in the public domain.
|
||||||
|
|
||||||
@ -81,7 +81,7 @@ void setup() {
|
|||||||
|
|
||||||
//Set math model to calculate the PPM concentration and the value of constants
|
//Set math model to calculate the PPM concentration and the value of constants
|
||||||
MQ135.setRegressionMethod(1); //_PPM = a*ratio^b
|
MQ135.setRegressionMethod(1); //_PPM = a*ratio^b
|
||||||
MQ135.setA(102.2); MQ135.setB(-2.473); // Configurate the ecuation values to get NH4 concentration
|
MQ135.setA(102.2); MQ135.setB(-2.473); // Configure the equation to to calculate NH4 concentration
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Exponential regression:
|
Exponential regression:
|
||||||
@ -89,9 +89,9 @@ void setup() {
|
|||||||
CO | 605.18 | -3.937
|
CO | 605.18 | -3.937
|
||||||
Alcohol | 77.255 | -3.18
|
Alcohol | 77.255 | -3.18
|
||||||
CO2 | 110.47 | -2.862
|
CO2 | 110.47 | -2.862
|
||||||
Tolueno | 44.947 | -3.445
|
Toluen | 44.947 | -3.445
|
||||||
NH4 | 102.2 | -2.473
|
NH4 | 102.2 | -2.473
|
||||||
Acetona | 34.668 | -3.369
|
Aceton | 34.668 | -3.369
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/***************************** MQ Init ********************************************/
|
/***************************** MQ Init ********************************************/
|
||||||
@ -104,24 +104,24 @@ void setup() {
|
|||||||
*/
|
*/
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
// Explanation:
|
// Explanation:
|
||||||
// In this routine the sensor will measure the resistance of the sensor supposing before was pre-heated
|
// In this routine the sensor will measure the resistance of the sensor supposedly before being pre-heated
|
||||||
// and now is on clean air (Calibration conditions), and it will setup R0 value.
|
// and on clean air (Calibration conditions), setting up R0 value.
|
||||||
// We recomend execute this routine only on setup or on the laboratory and save on the eeprom of your arduino
|
// We recomend executing this routine only on setup in laboratory conditions.
|
||||||
// This routine not need to execute to every restart, you can load your R0 if you know the value
|
// This routine does not need to be executed on each restart, you can load your R0 value from eeprom.
|
||||||
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
||||||
Serial.print("Calibrating please wait.");
|
Serial.print("Calibrating please wait.");
|
||||||
float calcR0 = 0;
|
float calcR0 = 0;
|
||||||
for(int i = 1; i<=10; i ++)
|
for(int i = 1; i<=10; i ++)
|
||||||
{
|
{
|
||||||
MQ135.update(); // Update data, the arduino will be read the voltage on the analog pin
|
MQ135.update(); // Update data, the arduino will read the voltage from the analog pin
|
||||||
calcR0 += MQ135.calibrate(RatioMQ135CleanAir);
|
calcR0 += MQ135.calibrate(RatioMQ135CleanAir);
|
||||||
Serial.print(".");
|
Serial.print(".");
|
||||||
}
|
}
|
||||||
MQ135.setR0(calcR0/10);
|
MQ135.setR0(calcR0/10);
|
||||||
Serial.println(" done!.");
|
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(isinf(calcR0)) {Serial.println("Warning: Conection issue, R0 is infinite (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);}
|
if(calcR0 == 0){Serial.println("Warning: Conection issue found, R0 is zero (Analog pin shorts to ground) please check your wiring and supply"); while(1);}
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
MQ135.serialDebug(true);
|
MQ135.serialDebug(true);
|
||||||
// Set delay between sensor readings based on sensor details.
|
// Set delay between sensor readings based on sensor details.
|
||||||
@ -138,8 +138,8 @@ void loop() {
|
|||||||
float cFactor = 0;
|
float cFactor = 0;
|
||||||
if (!isnan(event.temperature) && !isnan(event.relative_humidity)) cFactor = getCorrectionFactor(event.temperature, event.relative_humidity);
|
if (!isnan(event.temperature) && !isnan(event.relative_humidity)) cFactor = getCorrectionFactor(event.temperature, event.relative_humidity);
|
||||||
Serial.print("Correction Factor: "); Serial.println(cFactor);
|
Serial.print("Correction Factor: "); Serial.println(cFactor);
|
||||||
MQ135.update(); // Update data, the arduino will be read the voltage on the analog pin
|
MQ135.update(); // Update data, the arduino will read the voltage from the analog pin
|
||||||
MQ135.readSensor(false, cFactor); // Sensor will read PPM concentration using the model and a and b values setted before or in the setup
|
MQ135.readSensor(false, cFactor); // Sensor will read PPM concentration using the model, a and b values set previously or from the setup
|
||||||
MQ135.serialDebug(); // Will print the table on the serial port
|
MQ135.serialDebug(); // Will print the table on the serial port
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
Wiring:
|
Wiring:
|
||||||
https://github.com/miguel5612/MQSensorsLib_Docs/blob/master/static/img/MQ_Arduino.PNG
|
https://github.com/miguel5612/MQSensorsLib_Docs/blob/master/static/img/MQ_Arduino.PNG
|
||||||
Please take care, arduino A0 pin represent the analog input configured on #define pin
|
Please make sure arduino A0 pin represents the analog input configured on #define pin
|
||||||
|
|
||||||
This example code is in the public domain.
|
This example code is in the public domain.
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ void setup() {
|
|||||||
|
|
||||||
//Set math model to calculate the PPM concentration and the value of constants
|
//Set math model to calculate the PPM concentration and the value of constants
|
||||||
MQ135.setRegressionMethod(1); //_PPM = a*ratio^b
|
MQ135.setRegressionMethod(1); //_PPM = a*ratio^b
|
||||||
MQ135.setA(102.2); MQ135.setB(-2.473); // Configurate the ecuation values to get NH4 concentration
|
MQ135.setA(102.2); MQ135.setB(-2.473); // Configure the equation to to calculate NH4 concentration
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Exponential regression:
|
Exponential regression:
|
||||||
@ -50,9 +50,9 @@ void setup() {
|
|||||||
CO | 605.18 | -3.937
|
CO | 605.18 | -3.937
|
||||||
Alcohol | 77.255 | -3.18
|
Alcohol | 77.255 | -3.18
|
||||||
CO2 | 110.47 | -2.862
|
CO2 | 110.47 | -2.862
|
||||||
Tolueno | 44.947 | -3.445
|
Toluen | 44.947 | -3.445
|
||||||
NH4 | 102.2 | -2.473
|
NH4 | 102.2 | -2.473
|
||||||
Acetona | 34.668 | -3.369
|
Aceton | 34.668 | -3.369
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/***************************** MQ Init ********************************************/
|
/***************************** MQ Init ********************************************/
|
||||||
@ -65,31 +65,31 @@ void setup() {
|
|||||||
*/
|
*/
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
// Explanation:
|
// Explanation:
|
||||||
// In this routine the sensor will measure the resistance of the sensor supposing before was pre-heated
|
// In this routine the sensor will measure the resistance of the sensor supposedly before being pre-heated
|
||||||
// and now is on clean air (Calibration conditions), and it will setup R0 value.
|
// and on clean air (Calibration conditions), setting up R0 value.
|
||||||
// We recomend execute this routine only on setup or on the laboratory and save on the eeprom of your arduino
|
// We recomend executing this routine only on setup in laboratory conditions.
|
||||||
// This routine not need to execute to every restart, you can load your R0 if you know the value
|
// This routine does not need to be executed on each restart, you can load your R0 value from eeprom.
|
||||||
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
||||||
Serial.print("Calibrating please wait.");
|
Serial.print("Calibrating please wait.");
|
||||||
float calcR0 = 0;
|
float calcR0 = 0;
|
||||||
for(int i = 1; i<=10; i ++)
|
for(int i = 1; i<=10; i ++)
|
||||||
{
|
{
|
||||||
MQ135.update(); // Update data, the arduino will be read the voltage on the analog pin
|
MQ135.update(); // Update data, the arduino will read the voltage from the analog pin
|
||||||
calcR0 += MQ135.calibrate(RatioMQ135CleanAir);
|
calcR0 += MQ135.calibrate(RatioMQ135CleanAir);
|
||||||
Serial.print(".");
|
Serial.print(".");
|
||||||
}
|
}
|
||||||
MQ135.setR0(calcR0/10);
|
MQ135.setR0(calcR0/10);
|
||||||
Serial.println(" done!.");
|
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(isinf(calcR0)) {Serial.println("Warning: Conection issue, R0 is infinite (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);}
|
if(calcR0 == 0){Serial.println("Warning: Conection issue found, R0 is zero (Analog pin shorts to ground) please check your wiring and supply"); while(1);}
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
MQ135.serialDebug(true);
|
MQ135.serialDebug(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
MQ135.update(); // Update data, the arduino will be read the voltage on the analog pin
|
MQ135.update(); // Update data, the arduino will read the voltage from the analog pin
|
||||||
MQ135.readSensor(); // Sensor will read PPM concentration using the model and a and b values setted before or in the setup
|
MQ135.readSensor(); // Sensor will read PPM concentration using the model, a and b values set previously or from the setup
|
||||||
MQ135.serialDebug(); // Will print the table on the serial port
|
MQ135.serialDebug(); // Will print the table on the serial port
|
||||||
delay(500); //Sampling frequency
|
delay(500); //Sampling frequency
|
||||||
}
|
}
|
@ -14,7 +14,7 @@
|
|||||||
by Miguel Califa
|
by Miguel Califa
|
||||||
Wiring:
|
Wiring:
|
||||||
https://github.com/miguel5612/MQSensorsLib_Docs/blob/master/static/img/MQ_Arduino.PNG
|
https://github.com/miguel5612/MQSensorsLib_Docs/blob/master/static/img/MQ_Arduino.PNG
|
||||||
Please take care, arduino A0 pin represent the analog input configured on #define pin
|
Please make sure arduino A0 pin represents the analog input configured on #define pin
|
||||||
|
|
||||||
This example code is in the public domain.
|
This example code is in the public domain.
|
||||||
|
|
||||||
@ -41,7 +41,7 @@ void setup() {
|
|||||||
|
|
||||||
//Set math model to calculate the PPM concentration and the value of constants
|
//Set math model to calculate the PPM concentration and the value of constants
|
||||||
MQ2.setRegressionMethod(1); //_PPM = a*ratio^b
|
MQ2.setRegressionMethod(1); //_PPM = a*ratio^b
|
||||||
MQ2.setA(574.25); MQ2.setB(-2.222); // Configurate the ecuation values to get LPG concentration
|
MQ2.setA(574.25); MQ2.setB(-2.222); // Configure the equation to to calculate LPG concentration
|
||||||
/*
|
/*
|
||||||
Exponential regression:
|
Exponential regression:
|
||||||
Gas | a | b
|
Gas | a | b
|
||||||
@ -62,32 +62,32 @@ void setup() {
|
|||||||
*/
|
*/
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
// Explanation:
|
// Explanation:
|
||||||
// In this routine the sensor will measure the resistance of the sensor supposing before was pre-heated
|
// In this routine the sensor will measure the resistance of the sensor supposedly before being pre-heated
|
||||||
// and now is on clean air (Calibration conditions), and it will setup R0 value.
|
// and on clean air (Calibration conditions), setting up R0 value.
|
||||||
// We recomend execute this routine only on setup or on the laboratory and save on the eeprom of your arduino
|
// We recomend executing this routine only on setup in laboratory conditions.
|
||||||
// This routine not need to execute to every restart, you can load your R0 if you know the value
|
// This routine does not need to be executed on each restart, you can load your R0 value from eeprom.
|
||||||
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
||||||
Serial.print("Calibrating please wait.");
|
Serial.print("Calibrating please wait.");
|
||||||
float calcR0 = 0;
|
float calcR0 = 0;
|
||||||
for(int i = 1; i<=10; i ++)
|
for(int i = 1; i<=10; i ++)
|
||||||
{
|
{
|
||||||
MQ2.update(); // Update data, the arduino will be read the voltage on the analog pin
|
MQ2.update(); // Update data, the arduino will read the voltage from the analog pin
|
||||||
calcR0 += MQ2.calibrate(RatioMQ2CleanAir);
|
calcR0 += MQ2.calibrate(RatioMQ2CleanAir);
|
||||||
Serial.print(".");
|
Serial.print(".");
|
||||||
}
|
}
|
||||||
MQ2.setR0(calcR0/10);
|
MQ2.setR0(calcR0/10);
|
||||||
Serial.println(" done!.");
|
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(isinf(calcR0)) {Serial.println("Warning: Conection issue, R0 is infinite (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);}
|
if(calcR0 == 0){Serial.println("Warning: Conection issue found, R0 is zero (Analog pin shorts to ground) please check your wiring and supply"); while(1);}
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
|
|
||||||
MQ2.serialDebug(true);
|
MQ2.serialDebug(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
MQ2.update(); // Update data, the arduino will be read the voltage on the analog pin
|
MQ2.update(); // Update data, the arduino will read the voltage from the analog pin
|
||||||
MQ2.readSensor(); // Sensor will read PPM concentration using the model and a and b values setted before or in the setup
|
MQ2.readSensor(); // Sensor will read PPM concentration using the model, a and b values set previously or from the setup
|
||||||
MQ2.serialDebug(); // Will print the table on the serial port
|
MQ2.serialDebug(); // Will print the table on the serial port
|
||||||
delay(500); //Sampling frequency
|
delay(500); //Sampling frequency
|
||||||
}
|
}
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
Wiring:
|
Wiring:
|
||||||
https://github.com/miguel5612/MQSensorsLib_Docs/blob/master/static/img/MQ_Arduino.PNG
|
https://github.com/miguel5612/MQSensorsLib_Docs/blob/master/static/img/MQ_Arduino.PNG
|
||||||
Please take care, arduino A0 pin represent the analog input configured on #define pin
|
Please make sure arduino A0 pin represents the analog input configured on #define pin
|
||||||
|
|
||||||
This example code is in the public domain.
|
This example code is in the public domain.
|
||||||
|
|
||||||
@ -41,7 +41,7 @@ void setup() {
|
|||||||
|
|
||||||
//Set math model to calculate the PPM concentration and the value of constants
|
//Set math model to calculate the PPM concentration and the value of constants
|
||||||
MQ3.setRegressionMethod(1); //_PPM = a*ratio^b
|
MQ3.setRegressionMethod(1); //_PPM = a*ratio^b
|
||||||
MQ3.setA(4.8387); MQ3.setB(-2.68); // Configurate the ecuation values to get Benzene concentration
|
MQ3.setA(4.8387); MQ3.setB(-2.68); // Configure the equation to to calculate Benzene concentration
|
||||||
/*
|
/*
|
||||||
Exponential regression:
|
Exponential regression:
|
||||||
Gas | a | b
|
Gas | a | b
|
||||||
@ -64,31 +64,31 @@ void setup() {
|
|||||||
*/
|
*/
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
// Explanation:
|
// Explanation:
|
||||||
// In this routine the sensor will measure the resistance of the sensor supposing before was pre-heated
|
// In this routine the sensor will measure the resistance of the sensor supposedly before being pre-heated
|
||||||
// and now is on clean air (Calibration conditions), and it will setup R0 value.
|
// and on clean air (Calibration conditions), setting up R0 value.
|
||||||
// We recomend execute this routine only on setup or on the laboratory and save on the eeprom of your arduino
|
// We recomend executing this routine only on setup in laboratory conditions.
|
||||||
// This routine not need to execute to every restart, you can load your R0 if you know the value
|
// This routine does not need to be executed on each restart, you can load your R0 value from eeprom.
|
||||||
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
||||||
Serial.print("Calibrating please wait.");
|
Serial.print("Calibrating please wait.");
|
||||||
float calcR0 = 0;
|
float calcR0 = 0;
|
||||||
for(int i = 1; i<=10; i ++)
|
for(int i = 1; i<=10; i ++)
|
||||||
{
|
{
|
||||||
MQ3.update(); // Update data, the arduino will be read the voltage on the analog pin
|
MQ3.update(); // Update data, the arduino will read the voltage from the analog pin
|
||||||
calcR0 += MQ3.calibrate(RatioMQ3CleanAir);
|
calcR0 += MQ3.calibrate(RatioMQ3CleanAir);
|
||||||
Serial.print(".");
|
Serial.print(".");
|
||||||
}
|
}
|
||||||
MQ3.setR0(calcR0/10);
|
MQ3.setR0(calcR0/10);
|
||||||
Serial.println(" done!.");
|
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(isinf(calcR0)) {Serial.println("Warning: Conection issue, R0 is infinite (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);}
|
if(calcR0 == 0){Serial.println("Warning: Conection issue found, R0 is zero (Analog pin shorts to ground) please check your wiring and supply"); while(1);}
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
MQ3.serialDebug(true);
|
MQ3.serialDebug(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
MQ3.update(); // Update data, the arduino will be read the voltage on the analog pin
|
MQ3.update(); // Update data, the arduino will read the voltage from the analog pin
|
||||||
MQ3.readSensor(); // Sensor will read PPM concentration using the model and a and b values setted before or in the setup
|
MQ3.readSensor(); // Sensor will read PPM concentration using the model, a and b values set previously or from the setup
|
||||||
MQ3.serialDebug(); // Will print the table on the serial port
|
MQ3.serialDebug(); // Will print the table on the serial port
|
||||||
delay(500); //Sampling frequency
|
delay(500); //Sampling frequency
|
||||||
}
|
}
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
Wiring:
|
Wiring:
|
||||||
https://github.com/miguel5612/MQSensorsLib_Docs/blob/master/static/img/MQ_Arduino.PNG
|
https://github.com/miguel5612/MQSensorsLib_Docs/blob/master/static/img/MQ_Arduino.PNG
|
||||||
Please take care, arduino A0 pin represent the analog input configured on #define pin
|
Please make sure arduino A0 pin represents the analog input configured on #define pin
|
||||||
|
|
||||||
This example code is in the public domain.
|
This example code is in the public domain.
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ void setup() {
|
|||||||
|
|
||||||
//Set math model to calculate the PPM concentration and the value of constants
|
//Set math model to calculate the PPM concentration and the value of constants
|
||||||
MQ303.setRegressionMethod(1); //_PPM = a*ratio^b
|
MQ303.setRegressionMethod(1); //_PPM = a*ratio^b
|
||||||
MQ303.setA(6.2144); MQ303.setB(-2.894); // Configurate the ecuation values to get Isobutano concentration
|
MQ303.setA(6.2144); MQ303.setB(-2.894); // Configure the equation to to calculate Isobutano concentration
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Exponential regression:
|
Exponential regression:
|
||||||
@ -62,31 +62,31 @@ void setup() {
|
|||||||
*/
|
*/
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
// Explanation:
|
// Explanation:
|
||||||
// In this routine the sensor will measure the resistance of the sensor supposing before was pre-heated
|
// In this routine the sensor will measure the resistance of the sensor supposedly before being pre-heated
|
||||||
// and now is on clean air (Calibration conditions), and it will setup R0 value.
|
// and on clean air (Calibration conditions), setting up R0 value.
|
||||||
// We recomend execute this routine only on setup or on the laboratory and save on the eeprom of your arduino
|
// We recomend executing this routine only on setup in laboratory conditions.
|
||||||
// This routine not need to execute to every restart, you can load your R0 if you know the value
|
// This routine does not need to be executed on each restart, you can load your R0 value from eeprom.
|
||||||
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
||||||
Serial.print("Calibrating please wait.");
|
Serial.print("Calibrating please wait.");
|
||||||
float calcR0 = 0;
|
float calcR0 = 0;
|
||||||
for(int i = 1; i<=10; i ++)
|
for(int i = 1; i<=10; i ++)
|
||||||
{
|
{
|
||||||
MQ303.update(); // Update data, the arduino will be read the voltage on the analog pin
|
MQ303.update(); // Update data, the arduino will read the voltage from the analog pin
|
||||||
calcR0 += MQ303.calibrate(RatioMQ303CleanAir);
|
calcR0 += MQ303.calibrate(RatioMQ303CleanAir);
|
||||||
Serial.print(".");
|
Serial.print(".");
|
||||||
}
|
}
|
||||||
MQ303.setR0(calcR0/10);
|
MQ303.setR0(calcR0/10);
|
||||||
Serial.println(" done!.");
|
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(isinf(calcR0)) {Serial.println("Warning: Conection issue, R0 is infinite (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);}
|
if(calcR0 == 0){Serial.println("Warning: Conection issue found, R0 is zero (Analog pin shorts to ground) please check your wiring and supply"); while(1);}
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
MQ303.serialDebug(true);
|
MQ303.serialDebug(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
MQ303.update(); // Update data, the arduino will be read the voltage on the analog pin
|
MQ303.update(); // Update data, the arduino will read the voltage from the analog pin
|
||||||
MQ303.readSensor(true); // Sensor will read PPM concentration using the model and a and b values setted before or in the setup
|
MQ303.readSensor(true); // Sensor will read PPM concentration using the model, a and b values set previously or from the setup
|
||||||
MQ303.serialDebug(); // Will print the table on the serial port
|
MQ303.serialDebug(); // Will print the table on the serial port
|
||||||
delay(500); //Sampling frequency
|
delay(500); //Sampling frequency
|
||||||
}
|
}
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
Wiring:
|
Wiring:
|
||||||
https://github.com/miguel5612/MQSensorsLib_Docs/blob/master/static/img/MQ_Arduino.PNG
|
https://github.com/miguel5612/MQSensorsLib_Docs/blob/master/static/img/MQ_Arduino.PNG
|
||||||
Please take care, arduino A0 pin represent the analog input configured on #define pin
|
Please make sure arduino A0 pin represents the analog input configured on #define pin
|
||||||
|
|
||||||
This example code is in the public domain.
|
This example code is in the public domain.
|
||||||
|
|
||||||
@ -44,7 +44,7 @@ void setup() {
|
|||||||
|
|
||||||
//Set math model to calculate the PPM concentration and the value of constants
|
//Set math model to calculate the PPM concentration and the value of constants
|
||||||
MQ309.setRegressionMethod(1); //_PPM = a*ratio^b
|
MQ309.setRegressionMethod(1); //_PPM = a*ratio^b
|
||||||
MQ309.setA(1000000); MQ309.setB(-4.01); // Configurate the ecuation values to get CO concentration
|
MQ309.setA(1000000); MQ309.setB(-4.01); // Configure the equation to calculate CO concentration value
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Exponential regression:
|
Exponential regression:
|
||||||
@ -65,24 +65,24 @@ void setup() {
|
|||||||
*/
|
*/
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
// Explanation:
|
// Explanation:
|
||||||
// In this routine the sensor will measure the resistance of the sensor supposing before was pre-heated
|
// In this routine the sensor will measure the resistance of the sensor supposedly before being pre-heated
|
||||||
// and now is on clean air (Calibration conditions), and it will setup R0 value.
|
// and on clean air (Calibration conditions), setting up R0 value.
|
||||||
// We recomend execute this routine only on setup or on the laboratory and save on the eeprom of your arduino
|
// We recomend executing this routine only on setup in laboratory conditions.
|
||||||
// This routine not need to execute to every restart, you can load your R0 if you know the value
|
// This routine does not need to be executed on each restart, you can load your R0 value from eeprom.
|
||||||
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
||||||
Serial.print("Calibrating please wait.");
|
Serial.print("Calibrating please wait.");
|
||||||
float calcR0 = 0;
|
float calcR0 = 0;
|
||||||
for(int i = 1; i<=10; i ++)
|
for(int i = 1; i<=10; i ++)
|
||||||
{
|
{
|
||||||
MQ309.update(); // Update data, the arduino will be read the voltage on the analog pin
|
MQ309.update(); // Update data, the arduino will read the voltage from the analog pin
|
||||||
calcR0 += MQ309.calibrate(RatioMQ309CleanAir);
|
calcR0 += MQ309.calibrate(RatioMQ309CleanAir);
|
||||||
Serial.print(".");
|
Serial.print(".");
|
||||||
}
|
}
|
||||||
MQ309.setR0(calcR0/10);
|
MQ309.setR0(calcR0/10);
|
||||||
Serial.println(" done!.");
|
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(isinf(calcR0)) {Serial.println("Warning: Conection issue, R0 is infinite (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);}
|
if(calcR0 == 0){Serial.println("Warning: Conection issue found, R0 is zero (Analog pin shorts to ground) please check your wiring and supply"); while(1);}
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
MQ309.serialDebug(true);
|
MQ309.serialDebug(true);
|
||||||
}
|
}
|
||||||
@ -94,8 +94,8 @@ void loop() {
|
|||||||
{
|
{
|
||||||
// VH 0.9 Volts
|
// VH 0.9 Volts
|
||||||
analogWrite(5, 2); // 255 is 100%, 2.295 is aprox 0.9% of Duty cycle for 60s
|
analogWrite(5, 2); // 255 is 100%, 2.295 is aprox 0.9% of Duty cycle for 60s
|
||||||
MQ309.update(); // Update data, the arduino will be read the voltage on the analog pin
|
MQ309.update(); // Update data, the arduino will read the voltage from the analog pin
|
||||||
MQ309.readSensor(); // Sensor will read PPM concentration using the model and a and b values setted before or in the setup
|
MQ309.readSensor(); // Sensor will read PPM concentration using the model, a and b values set previously or from the setup
|
||||||
MQ309.serialDebug(); // Will print the table on the serial port
|
MQ309.serialDebug(); // Will print the table on the serial port
|
||||||
delay(500); //Sampling frequency
|
delay(500); //Sampling frequency
|
||||||
}
|
}
|
||||||
@ -106,8 +106,8 @@ void loop() {
|
|||||||
{
|
{
|
||||||
// VL 0.2 Volts
|
// VL 0.2 Volts
|
||||||
analogWrite(5, 1); // 255 is 100%, 0.51 is aprox 0.2% of Duty cycle for 120s
|
analogWrite(5, 1); // 255 is 100%, 0.51 is aprox 0.2% of Duty cycle for 120s
|
||||||
MQ309.update(); // Update data, the arduino will be read the voltage on the analog pin
|
MQ309.update(); // Update data, the arduino will read the voltage from the analog pin
|
||||||
MQ309.readSensor(); // Sensor will read PPM concentration using the model and a and b values setted before or in the setup
|
MQ309.readSensor(); // Sensor will read PPM concentration using the model, a and b values set previously or from the setup
|
||||||
MQ309.serialDebug(); // Will print the table on the serial port
|
MQ309.serialDebug(); // Will print the table on the serial port
|
||||||
delay(500); //Sampling frequency
|
delay(500); //Sampling frequency
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
Wiring:
|
Wiring:
|
||||||
https://github.com/miguel5612/MQSensorsLib_Docs/blob/master/static/img/MQ_Arduino.PNG
|
https://github.com/miguel5612/MQSensorsLib_Docs/blob/master/static/img/MQ_Arduino.PNG
|
||||||
Please take care, arduino A0 pin represent the analog input configured on #define pin
|
Please make sure arduino A0 pin represents the analog input configured on #define pin
|
||||||
|
|
||||||
This example code is in the public domain.
|
This example code is in the public domain.
|
||||||
|
|
||||||
@ -53,32 +53,32 @@ void setup() {
|
|||||||
*/
|
*/
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
// Explanation:
|
// Explanation:
|
||||||
// In this routine the sensor will measure the resistance of the sensor supposing before was pre-heated
|
// In this routine the sensor will measure the resistance of the sensor supposedly before being pre-heated
|
||||||
// and now is on clean air (Calibration conditions), and it will setup R0 value.
|
// and on clean air (Calibration conditions), setting up R0 value.
|
||||||
// We recomend execute this routine only on setup or on the laboratory and save on the eeprom of your arduino
|
// We recomend executing this routine only on setup in laboratory conditions.
|
||||||
// This routine not need to execute to every restart, you can load your R0 if you know the value
|
// This routine does not need to be executed on each restart, you can load your R0 value from eeprom.
|
||||||
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
||||||
Serial.print("Calibrating please wait.");
|
Serial.print("Calibrating please wait.");
|
||||||
float calcR0 = 0;
|
float calcR0 = 0;
|
||||||
for(int i = 1; i<=10; i ++)
|
for(int i = 1; i<=10; i ++)
|
||||||
{
|
{
|
||||||
MQ4.update(); // Update data, the arduino will be read the voltage on the analog pin
|
MQ4.update(); // Update data, the arduino will read the voltage from the analog pin
|
||||||
calcR0 += MQ4.calibrate(RatioMQ4CleanAir);
|
calcR0 += MQ4.calibrate(RatioMQ4CleanAir);
|
||||||
Serial.print(".");
|
Serial.print(".");
|
||||||
}
|
}
|
||||||
MQ4.setR0(calcR0/10);
|
MQ4.setR0(calcR0/10);
|
||||||
Serial.println(" done!.");
|
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(isinf(calcR0)) {Serial.println("Warning: Conection issue, R0 is infinite (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);}
|
if(calcR0 == 0){Serial.println("Warning: Conection issue found, R0 is zero (Analog pin shorts to ground) please check your wiring and supply"); while(1);}
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
|
|
||||||
Serial.println("*************** Lectures from MQ-4 **********************");
|
Serial.println("*************** Values from MQ-4 **********************");
|
||||||
Serial.println("| LPG | CH4 | CO | Alcohol | Smoke |");
|
Serial.println("| LPG | CH4 | CO | Alcohol | Smoke |");
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
MQ4.update(); // Update data, the arduino will be read the voltage on the analog pin
|
MQ4.update(); // Update data, the arduino will read the voltage from the analog pin
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Exponential regression:
|
Exponential regression:
|
||||||
@ -89,20 +89,20 @@ void loop() {
|
|||||||
Alcohol| 60000000000 | -14.01
|
Alcohol| 60000000000 | -14.01
|
||||||
smoke | 30000000 | -8.308
|
smoke | 30000000 | -8.308
|
||||||
*/
|
*/
|
||||||
MQ4.setA(3811.9); MQ4.setB(-3.113); // Configurate the ecuation values to get CH4 concentration
|
MQ4.setA(3811.9); MQ4.setB(-3.113); // Configure the equation to to calculate CH4 concentration
|
||||||
float LPG = MQ4.readSensor(); // Sensor will read PPM concentration using the model and a and b values setted before or in the setup
|
float LPG = MQ4.readSensor(); // Sensor will read PPM concentration using the model, a and b values set previously or from the setup
|
||||||
|
|
||||||
MQ4.setA(1012.7); MQ4.setB(-2.786); // Configurate the ecuation values to get CH4 concentration
|
MQ4.setA(1012.7); MQ4.setB(-2.786); // Configure the equation to to calculate CH4 concentration
|
||||||
float CH4 = MQ4.readSensor(); // Sensor will read PPM concentration using the model and a and b values setted before or in the setup
|
float CH4 = MQ4.readSensor(); // Sensor will read PPM concentration using the model, a and b values set previously or from the setup
|
||||||
|
|
||||||
MQ4.setA(200000000000000); MQ4.setB(-19.05); // Configurate the ecuation values to get CH4 concentration
|
MQ4.setA(200000000000000); MQ4.setB(-19.05); // Configure the equation to to calculate CH4 concentration
|
||||||
float CO = MQ4.readSensor(); // Sensor will read PPM concentration using the model and a and b values setted before or in the setup
|
float CO = MQ4.readSensor(); // Sensor will read PPM concentration using the model, a and b values set previously or from the setup
|
||||||
|
|
||||||
MQ4.setA(60000000000); MQ4.setB(-14.01); // Configurate the ecuation values to get CH4 concentration
|
MQ4.setA(60000000000); MQ4.setB(-14.01); // Configure the equation to to calculate CH4 concentration
|
||||||
float Alcohol = MQ4.readSensor(); // Sensor will read PPM concentration using the model and a and b values setted before or in the setup
|
float Alcohol = MQ4.readSensor(); // Sensor will read PPM concentration using the model, a and b values set previously or from the setup
|
||||||
|
|
||||||
MQ4.setA(30000000); MQ4.setB(-8.308); // Configurate the ecuation values to get CH4 concentration
|
MQ4.setA(30000000); MQ4.setB(-8.308); // Configure the equation to to calculate CH4 concentration
|
||||||
float Smoke = MQ4.readSensor(); // Sensor will read PPM concentration using the model and a and b values setted before or in the setup
|
float Smoke = MQ4.readSensor(); // Sensor will read PPM concentration using the model, a and b values set previously or from the setup
|
||||||
|
|
||||||
Serial.print("| "); Serial.print(LPG);
|
Serial.print("| "); Serial.print(LPG);
|
||||||
Serial.print(" | "); Serial.print(CH4);
|
Serial.print(" | "); Serial.print(CH4);
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
Wiring:
|
Wiring:
|
||||||
https://github.com/miguel5612/MQSensorsLib_Docs/blob/master/static/img/MQ_Arduino.PNG
|
https://github.com/miguel5612/MQSensorsLib_Docs/blob/master/static/img/MQ_Arduino.PNG
|
||||||
Please take care, arduino A0 pin represent the analog input configured on #define pin
|
Please make sure arduino A0 pin represents the analog input configured on #define pin
|
||||||
|
|
||||||
This example code is in the public domain.
|
This example code is in the public domain.
|
||||||
|
|
||||||
@ -52,36 +52,36 @@ void setup() {
|
|||||||
*/
|
*/
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
// Explanation:
|
// Explanation:
|
||||||
// In this routine the sensor will measure the resistance of the sensor supposing before was pre-heated
|
// In this routine the sensor will measure the resistance of the sensor supposedly before being pre-heated
|
||||||
// and now is on clean air (Calibration conditions), and it will setup R0 value.
|
// and on clean air (Calibration conditions), setting up R0 value.
|
||||||
// We recomend execute this routine only on setup or on the laboratory and save on the eeprom of your arduino
|
// We recomend executing this routine only on setup in laboratory conditions.
|
||||||
// This routine not need to execute to every restart, you can load your R0 if you know the value
|
// This routine does not need to be executed on each restart, you can load your R0 value from eeprom.
|
||||||
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
||||||
Serial.print("Calibrating please wait.");
|
Serial.print("Calibrating please wait.");
|
||||||
float calcR0 = 0;
|
float calcR0 = 0;
|
||||||
for(int i = 1; i<=10; i ++)
|
for(int i = 1; i<=10; i ++)
|
||||||
{
|
{
|
||||||
MQ4.update(); // Update data, the arduino will be read the voltage on the analog pin
|
MQ4.update(); // Update data, the arduino will read the voltage from the analog pin
|
||||||
calcR0 += MQ4.calibrate(RatioMQ4CleanAir);
|
calcR0 += MQ4.calibrate(RatioMQ4CleanAir);
|
||||||
Serial.print(".");
|
Serial.print(".");
|
||||||
}
|
}
|
||||||
MQ4.setR0(calcR0/10);
|
MQ4.setR0(calcR0/10);
|
||||||
Serial.println(" done!.");
|
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(isinf(calcR0)) {Serial.println("Warning: Conection issue, R0 is infinite (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);}
|
if(calcR0 == 0){Serial.println("Warning: Conection issue found, R0 is zero (Analog pin shorts to ground) please check your wiring and supply"); while(1);}
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
|
|
||||||
Serial.println("** Lectures from MQ-4**********");
|
Serial.println("** Values from MQ-4**********");
|
||||||
Serial.println("| LPG |");
|
Serial.println("| LPG |");
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
MQ4.update(); // Update data, the arduino will be read the voltage on the analog pin
|
MQ4.update(); // Update data, the arduino will read the voltage from the analog pin
|
||||||
|
|
||||||
//https://jayconsystems.com/blog/understanding-a-gas-sensor
|
//https://jayconsystems.com/blog/understanding-a-gas-sensor
|
||||||
MQ4.setA(-0.318); MQ4.setB(1.133); // A -> Slope, B -> Intersect with X - Axis
|
MQ4.setA(-0.318); MQ4.setB(1.133); // A -> Slope, B -> Intersect with X - Axis
|
||||||
float LPG = MQ4.readSensor(); // Sensor will read PPM concentration using the model and a and b values setted before or in the setup
|
float LPG = MQ4.readSensor(); // Sensor will read PPM concentration using the model, a and b values set previously or from the setup
|
||||||
|
|
||||||
// exposure to 2000 ppm of LPG gas is immediately dangerous to life and health. In this section
|
// exposure to 2000 ppm of LPG gas is immediately dangerous to life and health. In this section
|
||||||
if(LPG>=2000) Serial.println("Warning - Very high concentrations detected!");
|
if(LPG>=2000) Serial.println("Warning - Very high concentrations detected!");
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
Wiring:
|
Wiring:
|
||||||
https://github.com/miguel5612/MQSensorsLib_Docs/blob/master/static/img/MQ_Arduino.PNG
|
https://github.com/miguel5612/MQSensorsLib_Docs/blob/master/static/img/MQ_Arduino.PNG
|
||||||
Please take care, arduino A0 pin represent the analog input configured on #define pin
|
Please make sure arduino A0 pin represents the analog input configured on #define pin
|
||||||
|
|
||||||
This example code is in the public domain.
|
This example code is in the public domain.
|
||||||
|
|
||||||
@ -41,7 +41,7 @@ void setup() {
|
|||||||
|
|
||||||
//Set math model to calculate the PPM concentration and the value of constants
|
//Set math model to calculate the PPM concentration and the value of constants
|
||||||
MQ4.setRegressionMethod(1); //_PPM = a*ratio^b
|
MQ4.setRegressionMethod(1); //_PPM = a*ratio^b
|
||||||
MQ4.setA(1012.7); MQ4.setB(-2.786); // Configurate the ecuation values to get CH4 concentration
|
MQ4.setA(1012.7); MQ4.setB(-2.786); // Configure the equation to to calculate CH4 concentration
|
||||||
/*
|
/*
|
||||||
Exponential regression:
|
Exponential regression:
|
||||||
Gas | a | b
|
Gas | a | b
|
||||||
@ -63,31 +63,31 @@ void setup() {
|
|||||||
*/
|
*/
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
// Explanation:
|
// Explanation:
|
||||||
// In this routine the sensor will measure the resistance of the sensor supposing before was pre-heated
|
// In this routine the sensor will measure the resistance of the sensor supposedly before being pre-heated
|
||||||
// and now is on clean air (Calibration conditions), and it will setup R0 value.
|
// and on clean air (Calibration conditions), setting up R0 value.
|
||||||
// We recomend execute this routine only on setup or on the laboratory and save on the eeprom of your arduino
|
// We recomend executing this routine only on setup in laboratory conditions.
|
||||||
// This routine not need to execute to every restart, you can load your R0 if you know the value
|
// This routine does not need to be executed on each restart, you can load your R0 value from eeprom.
|
||||||
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
||||||
Serial.print("Calibrating please wait.");
|
Serial.print("Calibrating please wait.");
|
||||||
float calcR0 = 0;
|
float calcR0 = 0;
|
||||||
for(int i = 1; i<=10; i ++)
|
for(int i = 1; i<=10; i ++)
|
||||||
{
|
{
|
||||||
MQ4.update(); // Update data, the arduino will be read the voltage on the analog pin
|
MQ4.update(); // Update data, the arduino will read the voltage from the analog pin
|
||||||
calcR0 += MQ4.calibrate(RatioMQ4CleanAir);
|
calcR0 += MQ4.calibrate(RatioMQ4CleanAir);
|
||||||
Serial.print(".");
|
Serial.print(".");
|
||||||
}
|
}
|
||||||
MQ4.setR0(calcR0/10);
|
MQ4.setR0(calcR0/10);
|
||||||
Serial.println(" done!.");
|
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(isinf(calcR0)) {Serial.println("Warning: Conection issue, R0 is infinite (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);}
|
if(calcR0 == 0){Serial.println("Warning: Conection issue found, R0 is zero (Analog pin shorts to ground) please check your wiring and supply"); while(1);}
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
MQ4.serialDebug(true);
|
MQ4.serialDebug(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
MQ4.update(); // Update data, the arduino will be read the voltage on the analog pin
|
MQ4.update(); // Update data, the arduino will read the voltage from the analog pin
|
||||||
MQ4.readSensor(); // Sensor will read PPM concentration using the model and a and b values setted before or in the setup
|
MQ4.readSensor(); // Sensor will read PPM concentration using the model, a and b values set previously or from the setup
|
||||||
MQ4.serialDebug(); // Will print the table on the serial port
|
MQ4.serialDebug(); // Will print the table on the serial port
|
||||||
delay(500); //Sampling frequency
|
delay(500); //Sampling frequency
|
||||||
}
|
}
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
Wiring:
|
Wiring:
|
||||||
https://github.com/miguel5612/MQSensorsLib_Docs/blob/master/static/img/MQ_Arduino.PNG
|
https://github.com/miguel5612/MQSensorsLib_Docs/blob/master/static/img/MQ_Arduino.PNG
|
||||||
Please take care, arduino A0 pin represent the analog input configured on #define pin
|
Please make sure arduino A0 pin represents the analog input configured on #define pin
|
||||||
|
|
||||||
This example code is in the public domain.
|
This example code is in the public domain.
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ void setup() {
|
|||||||
|
|
||||||
//Set math model to calculate the PPM concentration and the value of constants
|
//Set math model to calculate the PPM concentration and the value of constants
|
||||||
MQ5.setRegressionMethod(1); //_PPM = a*ratio^b
|
MQ5.setRegressionMethod(1); //_PPM = a*ratio^b
|
||||||
MQ5.setA(1163.8); MQ5.setB(-3.874); // Configurate the ecuation values to get H2 concentration
|
MQ5.setA(1163.8); MQ5.setB(-3.874); // Configure the equation to to calculate H2 concentration
|
||||||
/*
|
/*
|
||||||
Exponential regression:
|
Exponential regression:
|
||||||
Gas | a | b
|
Gas | a | b
|
||||||
@ -63,31 +63,31 @@ void setup() {
|
|||||||
*/
|
*/
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
// Explanation:
|
// Explanation:
|
||||||
// In this routine the sensor will measure the resistance of the sensor supposing before was pre-heated
|
// In this routine the sensor will measure the resistance of the sensor supposedly before being pre-heated
|
||||||
// and now is on clean air (Calibration conditions), and it will setup R0 value.
|
// and on clean air (Calibration conditions), setting up R0 value.
|
||||||
// We recomend execute this routine only on setup or on the laboratory and save on the eeprom of your arduino
|
// We recomend executing this routine only on setup in laboratory conditions.
|
||||||
// This routine not need to execute to every restart, you can load your R0 if you know the value
|
// This routine does not need to be executed on each restart, you can load your R0 value from eeprom.
|
||||||
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
||||||
Serial.print("Calibrating please wait.");
|
Serial.print("Calibrating please wait.");
|
||||||
float calcR0 = 0;
|
float calcR0 = 0;
|
||||||
for(int i = 1; i<=10; i ++)
|
for(int i = 1; i<=10; i ++)
|
||||||
{
|
{
|
||||||
MQ5.update(); // Update data, the arduino will be read the voltage on the analog pin
|
MQ5.update(); // Update data, the arduino will read the voltage from the analog pin
|
||||||
calcR0 += MQ5.calibrate(RatioMQ5CleanAir);
|
calcR0 += MQ5.calibrate(RatioMQ5CleanAir);
|
||||||
Serial.print(".");
|
Serial.print(".");
|
||||||
}
|
}
|
||||||
MQ5.setR0(calcR0/10);
|
MQ5.setR0(calcR0/10);
|
||||||
Serial.println(" done!.");
|
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(isinf(calcR0)) {Serial.println("Warning: Conection issue, R0 is infinite (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);}
|
if(calcR0 == 0){Serial.println("Warning: Conection issue found, R0 is zero (Analog pin shorts to ground) please check your wiring and supply"); while(1);}
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
MQ5.serialDebug(true);
|
MQ5.serialDebug(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
MQ5.update(); // Update data, the arduino will be read the voltage on the analog pin
|
MQ5.update(); // Update data, the arduino will read the voltage from the analog pin
|
||||||
MQ5.readSensor(); // Sensor will read PPM concentration using the model and a and b values setted before or in the setup
|
MQ5.readSensor(); // Sensor will read PPM concentration using the model, a and b values set previously or from the setup
|
||||||
MQ5.serialDebug(); // Will print the table on the serial port
|
MQ5.serialDebug(); // Will print the table on the serial port
|
||||||
delay(500); //Sampling frequency
|
delay(500); //Sampling frequency
|
||||||
}
|
}
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
Wiring:
|
Wiring:
|
||||||
https://github.com/miguel5612/MQSensorsLib_Docs/blob/master/static/img/MQ_Arduino.PNG
|
https://github.com/miguel5612/MQSensorsLib_Docs/blob/master/static/img/MQ_Arduino.PNG
|
||||||
Please take care, arduino A0 pin represent the analog input configured on #define pin
|
Please make sure arduino A0 pin represents the analog input configured on #define pin
|
||||||
|
|
||||||
This example code is in the public domain.
|
This example code is in the public domain.
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ void setup() {
|
|||||||
|
|
||||||
//Set math model to calculate the PPM concentration and the value of constants
|
//Set math model to calculate the PPM concentration and the value of constants
|
||||||
MQ6.setRegressionMethod(1); //_PPM = a*ratio^b
|
MQ6.setRegressionMethod(1); //_PPM = a*ratio^b
|
||||||
MQ6.setA(2127.2); MQ6.setB(-2.526); // Configurate the ecuation values to get CH4 concentration
|
MQ6.setA(2127.2); MQ6.setB(-2.526); // Configure the equation to to calculate CH4 concentration
|
||||||
/*
|
/*
|
||||||
Exponential regression:
|
Exponential regression:
|
||||||
GAS | a | b
|
GAS | a | b
|
||||||
@ -63,31 +63,31 @@ void setup() {
|
|||||||
*/
|
*/
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
// Explanation:
|
// Explanation:
|
||||||
// In this routine the sensor will measure the resistance of the sensor supposing before was pre-heated
|
// In this routine the sensor will measure the resistance of the sensor supposedly before being pre-heated
|
||||||
// and now is on clean air (Calibration conditions), and it will setup R0 value.
|
// and on clean air (Calibration conditions), setting up R0 value.
|
||||||
// We recomend execute this routine only on setup or on the laboratory and save on the eeprom of your arduino
|
// We recomend executing this routine only on setup in laboratory conditions.
|
||||||
// This routine not need to execute to every restart, you can load your R0 if you know the value
|
// This routine does not need to be executed on each restart, you can load your R0 value from eeprom.
|
||||||
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
||||||
Serial.print("Calibrating please wait.");
|
Serial.print("Calibrating please wait.");
|
||||||
float calcR0 = 0;
|
float calcR0 = 0;
|
||||||
for(int i = 1; i<=10; i ++)
|
for(int i = 1; i<=10; i ++)
|
||||||
{
|
{
|
||||||
MQ6.update(); // Update data, the arduino will be read the voltage on the analog pin
|
MQ6.update(); // Update data, the arduino will read the voltage from the analog pin
|
||||||
calcR0 += MQ6.calibrate(RatioMQ6CleanAir);
|
calcR0 += MQ6.calibrate(RatioMQ6CleanAir);
|
||||||
Serial.print(".");
|
Serial.print(".");
|
||||||
}
|
}
|
||||||
MQ6.setR0(calcR0/10);
|
MQ6.setR0(calcR0/10);
|
||||||
Serial.println(" done!.");
|
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(isinf(calcR0)) {Serial.println("Warning: Conection issue, R0 is infinite (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);}
|
if(calcR0 == 0){Serial.println("Warning: Conection issue found, R0 is zero (Analog pin shorts to ground) please check your wiring and supply"); while(1);}
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
MQ6.serialDebug(true);
|
MQ6.serialDebug(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
MQ6.update(); // Update data, the arduino will be read the voltage on the analog pin
|
MQ6.update(); // Update data, the arduino will read the voltage from the analog pin
|
||||||
MQ6.readSensor(); // Sensor will read PPM concentration using the model and a and b values setted before or in the setup
|
MQ6.readSensor(); // Sensor will read PPM concentration using the model, a and b values set previously or from the setup
|
||||||
MQ6.serialDebug(); // Will print the table on the serial port
|
MQ6.serialDebug(); // Will print the table on the serial port
|
||||||
delay(500); //Sampling frequency
|
delay(500); //Sampling frequency
|
||||||
}
|
}
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
Wiring:
|
Wiring:
|
||||||
https://github.com/miguel5612/MQSensorsLib_Docs/blob/master/static/img/MQ_Arduino.PNG
|
https://github.com/miguel5612/MQSensorsLib_Docs/blob/master/static/img/MQ_Arduino.PNG
|
||||||
Please take care, arduino A0 pin represent the analog input configured on #define pin
|
Please make sure arduino A0 pin represents the analog input configured on #define pin
|
||||||
|
|
||||||
This example code is in the public domain.
|
This example code is in the public domain.
|
||||||
|
|
||||||
@ -48,7 +48,7 @@ void setup() {
|
|||||||
|
|
||||||
//Set math model to calculate the PPM concentration and the value of constants
|
//Set math model to calculate the PPM concentration and the value of constants
|
||||||
MQ7.setRegressionMethod(1); //_PPM = a*ratio^b
|
MQ7.setRegressionMethod(1); //_PPM = a*ratio^b
|
||||||
MQ7.setA(99.042); MQ7.setB(-1.518); // Configurate the ecuation values to get CO concentration
|
MQ7.setA(99.042); MQ7.setB(-1.518); // Configure the equation to calculate CO concentration value
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Exponential regression:
|
Exponential regression:
|
||||||
@ -70,24 +70,24 @@ void setup() {
|
|||||||
*/
|
*/
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
// Explanation:
|
// Explanation:
|
||||||
// In this routine the sensor will measure the resistance of the sensor supposing before was pre-heated
|
// In this routine the sensor will measure the resistance of the sensor supposedly before being pre-heated
|
||||||
// and now is on clean air (Calibration conditions), and it will setup R0 value.
|
// and on clean air (Calibration conditions), setting up R0 value.
|
||||||
// We recomend execute this routine only on setup or on the laboratory and save on the eeprom of your arduino
|
// We recomend executing this routine only on setup in laboratory conditions.
|
||||||
// This routine not need to execute to every restart, you can load your R0 if you know the value
|
// This routine does not need to be executed on each restart, you can load your R0 value from eeprom.
|
||||||
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
||||||
Serial.print("Calibrating please wait.");
|
Serial.print("Calibrating please wait.");
|
||||||
float calcR0 = 0;
|
float calcR0 = 0;
|
||||||
for(int i = 1; i<=10; i ++)
|
for(int i = 1; i<=10; i ++)
|
||||||
{
|
{
|
||||||
MQ7.update(); // Update data, the arduino will be read the voltage on the analog pin
|
MQ7.update(); // Update data, the arduino will read the voltage from the analog pin
|
||||||
calcR0 += MQ7.calibrate(RatioMQ7CleanAir);
|
calcR0 += MQ7.calibrate(RatioMQ7CleanAir);
|
||||||
Serial.print(".");
|
Serial.print(".");
|
||||||
}
|
}
|
||||||
MQ7.setR0(calcR0/10);
|
MQ7.setR0(calcR0/10);
|
||||||
Serial.println(" done!.");
|
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(isinf(calcR0)) {Serial.println("Warning: Conection issue, R0 is infinite (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);}
|
if(calcR0 == 0){Serial.println("Warning: Conection issue found, R0 is zero (Analog pin shorts to ground) please check your wiring and supply"); while(1);}
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
MQ7.serialDebug(true);
|
MQ7.serialDebug(true);
|
||||||
}
|
}
|
||||||
@ -99,8 +99,8 @@ void loop() {
|
|||||||
{
|
{
|
||||||
// VH 5 Volts
|
// VH 5 Volts
|
||||||
analogWrite(5, 255); // 255 is DC 5V output
|
analogWrite(5, 255); // 255 is DC 5V output
|
||||||
MQ7.update(); // Update data, the arduino will be read the voltage on the analog pin
|
MQ7.update(); // Update data, the arduino will read the voltage from the analog pin
|
||||||
MQ7.readSensor(); // Sensor will read PPM concentration using the model and a and b values setted before or in the setup
|
MQ7.readSensor(); // Sensor will read PPM concentration using the model, a and b values set previously or from the setup
|
||||||
MQ7.serialDebug(); // Will print the table on the serial port
|
MQ7.serialDebug(); // Will print the table on the serial port
|
||||||
delay(500); //Sampling frequency
|
delay(500); //Sampling frequency
|
||||||
}
|
}
|
||||||
@ -111,8 +111,8 @@ void loop() {
|
|||||||
{
|
{
|
||||||
// VH 1.4 Volts
|
// VH 1.4 Volts
|
||||||
analogWrite(5, 20); // 255 is 100%, 20.4 is aprox 8% of Duty cycle for 90s
|
analogWrite(5, 20); // 255 is 100%, 20.4 is aprox 8% of Duty cycle for 90s
|
||||||
MQ7.update(); // Update data, the arduino will be read the voltage on the analog pin
|
MQ7.update(); // Update data, the arduino will read the voltage from the analog pin
|
||||||
MQ7.readSensor(); // Sensor will read PPM concentration using the model and a and b values setted before or in the setup
|
MQ7.readSensor(); // Sensor will read PPM concentration using the model, a and b values set previously or from the setup
|
||||||
MQ7.serialDebug(); // Will print the table on the serial port
|
MQ7.serialDebug(); // Will print the table on the serial port
|
||||||
delay(500); //Sampling frequency
|
delay(500); //Sampling frequency
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
Wiring:
|
Wiring:
|
||||||
https://github.com/miguel5612/MQSensorsLib_Docs/blob/master/static/img/MQ_Arduino.PNG
|
https://github.com/miguel5612/MQSensorsLib_Docs/blob/master/static/img/MQ_Arduino.PNG
|
||||||
Please take care, arduino A0 pin represent the analog input configured on #define pin
|
Please make sure arduino A0 pin represents the analog input configured on #define pin
|
||||||
|
|
||||||
This example code is in the public domain.
|
This example code is in the public domain.
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ void setup() {
|
|||||||
|
|
||||||
//Set math model to calculate the PPM concentration and the value of constants
|
//Set math model to calculate the PPM concentration and the value of constants
|
||||||
MQ8.setRegressionMethod(1); //_PPM = a*ratio^b
|
MQ8.setRegressionMethod(1); //_PPM = a*ratio^b
|
||||||
MQ8.setA(976.97); MQ8.setB(-0.688); // Configurate the ecuation values to get H2 concentration
|
MQ8.setA(976.97); MQ8.setB(-0.688); // Configure the equation to to calculate H2 concentration
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Exponential regression:
|
Exponential regression:
|
||||||
@ -64,31 +64,31 @@ void setup() {
|
|||||||
*/
|
*/
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
// Explanation:
|
// Explanation:
|
||||||
// In this routine the sensor will measure the resistance of the sensor supposing before was pre-heated
|
// In this routine the sensor will measure the resistance of the sensor supposedly before being pre-heated
|
||||||
// and now is on clean air (Calibration conditions), and it will setup R0 value.
|
// and on clean air (Calibration conditions), setting up R0 value.
|
||||||
// We recomend execute this routine only on setup or on the laboratory and save on the eeprom of your arduino
|
// We recomend executing this routine only on setup in laboratory conditions.
|
||||||
// This routine not need to execute to every restart, you can load your R0 if you know the value
|
// This routine does not need to be executed on each restart, you can load your R0 value from eeprom.
|
||||||
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
||||||
Serial.print("Calibrating please wait.");
|
Serial.print("Calibrating please wait.");
|
||||||
float calcR0 = 0;
|
float calcR0 = 0;
|
||||||
for(int i = 1; i<=10; i ++)
|
for(int i = 1; i<=10; i ++)
|
||||||
{
|
{
|
||||||
MQ8.update(); // Update data, the arduino will be read the voltage on the analog pin
|
MQ8.update(); // Update data, the arduino will read the voltage from the analog pin
|
||||||
calcR0 += MQ8.calibrate(RatioMQ8CleanAir);
|
calcR0 += MQ8.calibrate(RatioMQ8CleanAir);
|
||||||
Serial.print(".");
|
Serial.print(".");
|
||||||
}
|
}
|
||||||
MQ8.setR0(calcR0/10);
|
MQ8.setR0(calcR0/10);
|
||||||
Serial.println(" done!.");
|
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(isinf(calcR0)) {Serial.println("Warning: Conection issue, R0 is infinite (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);}
|
if(calcR0 == 0){Serial.println("Warning: Conection issue found, R0 is zero (Analog pin shorts to ground) please check your wiring and supply"); while(1);}
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
MQ8.serialDebug(true);
|
MQ8.serialDebug(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
MQ8.update(); // Update data, the arduino will be read the voltage on the analog pin
|
MQ8.update(); // Update data, the arduino will read the voltage from the analog pin
|
||||||
MQ8.readSensor(); // Sensor will read PPM concentration using the model and a and b values setted before or in the setup
|
MQ8.readSensor(); // Sensor will read PPM concentration using the model, a and b values set previously or from the setup
|
||||||
MQ8.serialDebug(); // Will print the table on the serial port
|
MQ8.serialDebug(); // Will print the table on the serial port
|
||||||
delay(500); //Sampling frequency
|
delay(500); //Sampling frequency
|
||||||
}
|
}
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
Wiring:
|
Wiring:
|
||||||
https://github.com/miguel5612/MQSensorsLib_Docs/blob/master/static/img/MQ_Arduino.PNG
|
https://github.com/miguel5612/MQSensorsLib_Docs/blob/master/static/img/MQ_Arduino.PNG
|
||||||
Please take care, arduino A0 pin represent the analog input configured on #define pin
|
Please make sure arduino A0 pin represents the analog input configured on #define pin
|
||||||
|
|
||||||
This example code is in the public domain.
|
This example code is in the public domain.
|
||||||
|
|
||||||
@ -53,31 +53,31 @@ void setup() {
|
|||||||
*/
|
*/
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
// Explanation:
|
// Explanation:
|
||||||
// In this routine the sensor will measure the resistance of the sensor supposing before was pre-heated
|
// In this routine the sensor will measure the resistance of the sensor supposedly before being pre-heated
|
||||||
// and now is on clean air (Calibration conditions), and it will setup R0 value.
|
// and on clean air (Calibration conditions), setting up R0 value.
|
||||||
// We recomend execute this routine only on setup or on the laboratory and save on the eeprom of your arduino
|
// We recomend executing this routine only on setup in laboratory conditions.
|
||||||
// This routine not need to execute to every restart, you can load your R0 if you know the value
|
// This routine does not need to be executed on each restart, you can load your R0 value from eeprom.
|
||||||
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
||||||
Serial.print("Calibrating please wait.");
|
Serial.print("Calibrating please wait.");
|
||||||
float calcR0 = 0;
|
float calcR0 = 0;
|
||||||
for(int i = 1; i<=10; i ++)
|
for(int i = 1; i<=10; i ++)
|
||||||
{
|
{
|
||||||
MQ9.update(); // Update data, the arduino will be read the voltage on the analog pin
|
MQ9.update(); // Update data, the arduino will read the voltage from the analog pin
|
||||||
calcR0 += MQ9.calibrate(RatioMQ9CleanAir);
|
calcR0 += MQ9.calibrate(RatioMQ9CleanAir);
|
||||||
Serial.print(".");
|
Serial.print(".");
|
||||||
}
|
}
|
||||||
MQ9.setR0(calcR0/10);
|
MQ9.setR0(calcR0/10);
|
||||||
Serial.println(" done!.");
|
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(isinf(calcR0)) {Serial.println("Warning: Conection issue, R0 is infinite (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);}
|
if(calcR0 == 0){Serial.println("Warning: Conection issue found, R0 is zero (Analog pin shorts to ground) please check your wiring and supply"); while(1);}
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
Serial.println("** Lectures from MQ-9 ****");
|
Serial.println("** Values from MQ-9 ****");
|
||||||
Serial.println("| LPG | CH4 | CO |");
|
Serial.println("| LPG | CH4 | CO |");
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
MQ9.update(); // Update data, the arduino will be read the voltage on the analog pin
|
MQ9.update(); // Update data, the arduino will read the voltage from the analog pin
|
||||||
/*
|
/*
|
||||||
Exponential regression:
|
Exponential regression:
|
||||||
GAS | a | b
|
GAS | a | b
|
||||||
@ -86,14 +86,14 @@ void loop() {
|
|||||||
CO | 599.65 | -2.244
|
CO | 599.65 | -2.244
|
||||||
*/
|
*/
|
||||||
|
|
||||||
MQ9.setA(1000.5); MQ9.setB(-2.186); // Configurate the ecuation values to get LPG concentration
|
MQ9.setA(1000.5); MQ9.setB(-2.186); // Configure the equation to to calculate LPG concentration
|
||||||
float LPG = MQ9.readSensor(); // Sensor will read PPM concentration using the model and a and b values setted before or in the setup
|
float LPG = MQ9.readSensor(); // Sensor will read PPM concentration using the model, a and b values set previously or from the setup
|
||||||
|
|
||||||
MQ9.setA(4269.6); MQ9.setB(-2.648); // Configurate the ecuation values to get LPG concentration
|
MQ9.setA(4269.6); MQ9.setB(-2.648); // Configure the equation to to calculate LPG concentration
|
||||||
float CH4 = MQ9.readSensor(); // Sensor will read PPM concentration using the model and a and b values setted before or in the setup
|
float CH4 = MQ9.readSensor(); // Sensor will read PPM concentration using the model, a and b values set previously or from the setup
|
||||||
|
|
||||||
MQ9.setA(599.65); MQ9.setB(-2.244); // Configurate the ecuation values to get LPG concentration
|
MQ9.setA(599.65); MQ9.setB(-2.244); // Configure the equation to to calculate LPG concentration
|
||||||
float CO = MQ9.readSensor(); // Sensor will read PPM concentration using the model and a and b values setted before or in the setup
|
float CO = MQ9.readSensor(); // Sensor will read PPM concentration using the model, a and b values set previously or from the setup
|
||||||
|
|
||||||
Serial.print("| "); Serial.print(LPG);
|
Serial.print("| "); Serial.print(LPG);
|
||||||
Serial.print(" | "); Serial.print(CH4);
|
Serial.print(" | "); Serial.print(CH4);
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
Wiring:
|
Wiring:
|
||||||
https://github.com/miguel5612/MQSensorsLib_Docs/blob/master/static/img/MQ_Arduino.PNG
|
https://github.com/miguel5612/MQSensorsLib_Docs/blob/master/static/img/MQ_Arduino.PNG
|
||||||
Please take care, arduino A0 pin represent the analog input configured on #define pin
|
Please make sure arduino A0 pin represents the analog input configured on #define pin
|
||||||
|
|
||||||
This example code is in the public domain.
|
This example code is in the public domain.
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ void setup() {
|
|||||||
|
|
||||||
//Set math model to calculate the PPM concentration and the value of constants
|
//Set math model to calculate the PPM concentration and the value of constants
|
||||||
MQ9.setRegressionMethod(1); //_PPM = a*ratio^b
|
MQ9.setRegressionMethod(1); //_PPM = a*ratio^b
|
||||||
MQ9.setA(1000.5); MQ9.setB(-2.186); // Configurate the ecuation values to get LPG concentration
|
MQ9.setA(1000.5); MQ9.setB(-2.186); // Configure the equation to to calculate LPG concentration
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Exponential regression:
|
Exponential regression:
|
||||||
@ -65,10 +65,10 @@ void setup() {
|
|||||||
*/
|
*/
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
// Explanation:
|
// Explanation:
|
||||||
// In this routine the sensor will measure the resistance of the sensor supposing before was pre-heated
|
// In this routine the sensor will measure the resistance of the sensor supposedly before being pre-heated
|
||||||
// and now is on clean air (Calibration conditions), and it will setup R0 value.
|
// and on clean air (Calibration conditions), setting up R0 value.
|
||||||
// We recomend execute this routine only on setup or on the laboratory and save on the eeprom of your arduino
|
// We recomend executing this routine only on setup in laboratory conditions.
|
||||||
// This routine not need to execute to every restart, you can load your R0 if you know the value
|
// This routine does not need to be executed on each restart, you can load your R0 value from eeprom.
|
||||||
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
||||||
// ISSUE 44 - MQ9 needs a low/high temperature cycle like MQ7 #44
|
// ISSUE 44 - MQ9 needs a low/high temperature cycle like MQ7 #44
|
||||||
|
|
||||||
@ -94,15 +94,15 @@ void setup() {
|
|||||||
float calcR0 = 0;
|
float calcR0 = 0;
|
||||||
for(int i = 1; i<=10; i ++)
|
for(int i = 1; i<=10; i ++)
|
||||||
{
|
{
|
||||||
MQ9.update(); // Update data, the arduino will be read the voltage on the analog pin
|
MQ9.update(); // Update data, the arduino will read the voltage from the analog pin
|
||||||
calcR0 += MQ9.calibrate(RatioMQ9CleanAir);
|
calcR0 += MQ9.calibrate(RatioMQ9CleanAir);
|
||||||
Serial.print(".");
|
Serial.print(".");
|
||||||
}
|
}
|
||||||
MQ9.setR0(calcR0/10);
|
MQ9.setR0(calcR0/10);
|
||||||
Serial.println(" done!.");
|
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(isinf(calcR0)) {Serial.println("Warning: Conection issue, R0 is infinite (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);}
|
if(calcR0 == 0){Serial.println("Warning: Conection issue found, R0 is zero (Analog pin shorts to ground) please check your wiring and supply"); while(1);}
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
MQ9.serialDebug(true);
|
MQ9.serialDebug(true);
|
||||||
}
|
}
|
||||||
@ -114,8 +114,8 @@ void loop() {
|
|||||||
digitalWrite(PreaheatControlPin5, HIGH);
|
digitalWrite(PreaheatControlPin5, HIGH);
|
||||||
digitalWrite(PreaheatControlPin14, LOW);
|
digitalWrite(PreaheatControlPin14, LOW);
|
||||||
|
|
||||||
MQ9.update(); // Update data, the arduino will be read the voltage on the analog pin
|
MQ9.update(); // Update data, the arduino will read the voltage from the analog pin
|
||||||
MQ9.readSensor(); // Sensor will read PPM concentration using the model and a and b values setted before or in the setup
|
MQ9.readSensor(); // Sensor will read PPM concentration using the model, a and b values set previously or from the setup
|
||||||
MQ9.serialDebug(); // Will print the table on the serial port
|
MQ9.serialDebug(); // Will print the table on the serial port
|
||||||
|
|
||||||
}
|
}
|
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
Wiring:
|
Wiring:
|
||||||
https://github.com/miguel5612/MQSensorsLib_Docs/blob/master/static/img/MQ_Arduino.PNG
|
https://github.com/miguel5612/MQSensorsLib_Docs/blob/master/static/img/MQ_Arduino.PNG
|
||||||
Please take care, arduino A0 pin represent the analog input configured on #define pin
|
Please make sure arduino A0 pin represents the analog input configured on #define pin
|
||||||
|
|
||||||
This example code is in the public domain.
|
This example code is in the public domain.
|
||||||
|
|
||||||
@ -61,50 +61,50 @@ void setup() {
|
|||||||
//init the sensor
|
//init the sensor
|
||||||
MQ2.init();
|
MQ2.init();
|
||||||
MQ2.setRegressionMethod(1); //_PPM = a*ratio^b
|
MQ2.setRegressionMethod(1); //_PPM = a*ratio^b
|
||||||
MQ2.setA(574.25); MQ2.setB(-2.222); // Configurate the ecuation values to get LPG concentration
|
MQ2.setA(574.25); MQ2.setB(-2.222); // Configure the equation to to calculate LPG concentration
|
||||||
MQ2.setR0(9.659574468);
|
MQ2.setR0(9.659574468);
|
||||||
|
|
||||||
MQ3.init();
|
MQ3.init();
|
||||||
MQ3.setRegressionMethod(1); //_PPM = a*ratio^b
|
MQ3.setRegressionMethod(1); //_PPM = a*ratio^b
|
||||||
MQ3.setA(0.3934); MQ3.setB(-1.504); // Configurate the ecuation values to get Alcohol concentration
|
MQ3.setA(0.3934); MQ3.setB(-1.504); //Configure the equation to calculate Alcohol concentration value
|
||||||
MQ3.setR0(3.86018237);
|
MQ3.setR0(3.86018237);
|
||||||
|
|
||||||
MQ4.init();
|
MQ4.init();
|
||||||
MQ4.setRegressionMethod(1); //_PPM = a*ratio^b
|
MQ4.setRegressionMethod(1); //_PPM = a*ratio^b
|
||||||
MQ4.setA(1012.7); MQ4.setB(-2.786); // Configurate the ecuation values to get CH4 concentration
|
MQ4.setA(1012.7); MQ4.setB(-2.786); // Configure the equation to to calculate CH4 concentration
|
||||||
MQ4.setR0(3.86018237);
|
MQ4.setR0(3.86018237);
|
||||||
|
|
||||||
MQ5.init();
|
MQ5.init();
|
||||||
MQ5.setRegressionMethod(1); //_PPM = a*ratio^b
|
MQ5.setRegressionMethod(1); //_PPM = a*ratio^b
|
||||||
MQ5.setA(97124); MQ5.setB(-4.918); // Configurate the ecuation values to get Alcohol concentration
|
MQ5.setA(97124); MQ5.setB(-4.918); //Configure the equation to calculate Alcohol concentration value
|
||||||
MQ5.setR0(71.100304);
|
MQ5.setR0(71.100304);
|
||||||
|
|
||||||
MQ6.init();
|
MQ6.init();
|
||||||
MQ6.setRegressionMethod(1); //_PPM = a*ratio^b
|
MQ6.setRegressionMethod(1); //_PPM = a*ratio^b
|
||||||
MQ6.setA(2127.2); MQ6.setB(-2.526); // Configurate the ecuation values to get CH4 concentration
|
MQ6.setA(2127.2); MQ6.setB(-2.526); // Configure the equation to to calculate CH4 concentration
|
||||||
MQ6.setR0(13.4285714);
|
MQ6.setR0(13.4285714);
|
||||||
|
|
||||||
MQ7.init();
|
MQ7.init();
|
||||||
MQ7.setRegressionMethod(1); //_PPM = a*ratio^b
|
MQ7.setRegressionMethod(1); //_PPM = a*ratio^b
|
||||||
MQ7.setA(99.042); MQ7.setB(-1.518); // Configurate the ecuation values to get CO concentration
|
MQ7.setA(99.042); MQ7.setB(-1.518); // Configure the equation to calculate CO concentration value
|
||||||
MQ7.setR0(4);
|
MQ7.setR0(4);
|
||||||
|
|
||||||
MQ8.init();
|
MQ8.init();
|
||||||
MQ8.setRegressionMethod(1); //_PPM = a*ratio^b
|
MQ8.setRegressionMethod(1); //_PPM = a*ratio^b
|
||||||
MQ8.setA(976.97); MQ8.setB(-0.688); // Configurate the ecuation values to get H2 concentration
|
MQ8.setA(976.97); MQ8.setB(-0.688); // Configure the equation to to calculate H2 concentration
|
||||||
MQ8.setR0(1);
|
MQ8.setR0(1);
|
||||||
|
|
||||||
MQ9.init();
|
MQ9.init();
|
||||||
MQ9.setRegressionMethod(1); //_PPM = a*ratio^b
|
MQ9.setRegressionMethod(1); //_PPM = a*ratio^b
|
||||||
MQ9.setA(1000.5); MQ9.setB(-2.186); // Configurate the ecuation values to get LPG concentration
|
MQ9.setA(1000.5); MQ9.setB(-2.186); // Configure the equation to to calculate LPG concentration
|
||||||
MQ9.setR0(9.42857143);
|
MQ9.setR0(9.42857143);
|
||||||
|
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
// Explanation:
|
// Explanation:
|
||||||
// In this routine the sensor will measure the resistance of the sensor supposing before was pre-heated
|
// In this routine the sensor will measure the resistance of the sensor supposedly before being pre-heated
|
||||||
// and now is on clean air (Calibration conditions), and it will setup R0 value.
|
// and on clean air (Calibration conditions), setting up R0 value.
|
||||||
// We recomend execute this routine only on setup or on the laboratory and save on the eeprom of your arduino
|
// We recomend executing this routine only on setup in laboratory conditions.
|
||||||
// This routine not need to execute to every restart, you can load your R0 if you know the value
|
// This routine does not need to be executed on each restart, you can load your R0 value from eeprom.
|
||||||
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
||||||
Serial.print("Calibrating please wait.");
|
Serial.print("Calibrating please wait.");
|
||||||
float MQ2calcR0 = 0,
|
float MQ2calcR0 = 0,
|
||||||
@ -117,7 +117,7 @@ void setup() {
|
|||||||
MQ9calcR0 = 0;
|
MQ9calcR0 = 0;
|
||||||
for(int i = 1; i<=10; i ++)
|
for(int i = 1; i<=10; i ++)
|
||||||
{
|
{
|
||||||
//Update the voltage lectures
|
//Update the voltage Values
|
||||||
MQ2.update();
|
MQ2.update();
|
||||||
MQ3.update();
|
MQ3.update();
|
||||||
MQ4.update();
|
MQ4.update();
|
||||||
@ -164,7 +164,7 @@ void setup() {
|
|||||||
|
|
||||||
//Print in serial monitor
|
//Print in serial monitor
|
||||||
Serial.println("MQ2 to MQ9 - lecture");
|
Serial.println("MQ2 to MQ9 - lecture");
|
||||||
Serial.println("*************************** Lectures from MQ-board ***************************");
|
Serial.println("*************************** Values from MQ-board ***************************");
|
||||||
Serial.println("| LPG | Alcohol | CH4 | Alcohol | CH4 | CO | H2 | LPG |");
|
Serial.println("| LPG | Alcohol | CH4 | Alcohol | CH4 | CO | H2 | LPG |");
|
||||||
Serial.println("| MQ-2 | MQ-3 | MQ-4 | MQ-5 | MQ-6 | MQ-7 | MQ-8 | MQ-9 |");
|
Serial.println("| MQ-2 | MQ-3 | MQ-4 | MQ-5 | MQ-6 | MQ-7 | MQ-8 | MQ-9 |");
|
||||||
//pinMode(calibration_button, INPUT);
|
//pinMode(calibration_button, INPUT);
|
||||||
@ -192,7 +192,7 @@ void loop() {
|
|||||||
|
|
||||||
void readAllSensors()
|
void readAllSensors()
|
||||||
{
|
{
|
||||||
//Update the voltage lectures
|
//Update the voltage Values
|
||||||
MQ2.update();
|
MQ2.update();
|
||||||
MQ3.update();
|
MQ3.update();
|
||||||
MQ4.update();
|
MQ4.update();
|
||||||
|
@ -85,13 +85,13 @@ void loop() {
|
|||||||
float CO2 = MQ135.readSensor(); // Sensor will read PPM concentration using the model, a and b values set previously or from the setup
|
float CO2 = MQ135.readSensor(); // Sensor will read PPM concentration using the model, a and b values set previously or from the setup
|
||||||
|
|
||||||
MQ135.setA(44.947); MQ135.setB(-3.445); // Configure the equation to calculate Toluen concentration value
|
MQ135.setA(44.947); MQ135.setB(-3.445); // Configure the equation to calculate Toluen concentration value
|
||||||
float Tolueno = MQ135.readSensor(); // Sensor will read PPM concentration using the model, a and b values set previously or from the setup
|
float Toluen = MQ135.readSensor(); // Sensor will read PPM concentration using the model, a and b values set previously or from the setup
|
||||||
|
|
||||||
MQ135.setA(102.2 ); MQ135.setB(-2.473); // Configure the equation to calculate NH4 concentration value
|
MQ135.setA(102.2 ); MQ135.setB(-2.473); // Configure the equation to calculate NH4 concentration value
|
||||||
float NH4 = MQ135.readSensor(); // Sensor will read PPM concentration using the model, a and b values set previously or from the setup
|
float NH4 = MQ135.readSensor(); // Sensor will read PPM concentration using the model, a and b values set previously or from the setup
|
||||||
|
|
||||||
MQ135.setA(34.668); MQ135.setB(-3.369); // Configure the equation to calculate Aceton concentration value
|
MQ135.setA(34.668); MQ135.setB(-3.369); // Configure the equation to calculate Aceton concentration value
|
||||||
float Acetona = MQ135.readSensor(); // Sensor will read PPM concentration using the model, a and b values set previously or from the setup
|
float Aceton = MQ135.readSensor(); // Sensor will read PPM concentration using the model, a and b values set previously or from the setup
|
||||||
Serial.print("| "); Serial.print(CO);
|
Serial.print("| "); Serial.print(CO);
|
||||||
Serial.print(" | "); Serial.print(Alcohol);
|
Serial.print(" | "); Serial.print(Alcohol);
|
||||||
// Note: 200 Offset for CO2 source: https://github.com/miguel5612/MQSensorsLib/issues/29
|
// Note: 200 Offset for CO2 source: https://github.com/miguel5612/MQSensorsLib/issues/29
|
||||||
@ -105,9 +105,9 @@ void loop() {
|
|||||||
https://www.lavanguardia.com/natural/20190514/462242832581/concentracion-dioxido-cabono-co2-atmosfera-bate-record-historia-humanidad.html
|
https://www.lavanguardia.com/natural/20190514/462242832581/concentracion-dioxido-cabono-co2-atmosfera-bate-record-historia-humanidad.html
|
||||||
*/
|
*/
|
||||||
Serial.print(" | "); Serial.print(CO2 + 400);
|
Serial.print(" | "); Serial.print(CO2 + 400);
|
||||||
Serial.print(" | "); Serial.print(Tolueno);
|
Serial.print(" | "); Serial.print(Toluen);
|
||||||
Serial.print(" | "); Serial.print(NH4);
|
Serial.print(" | "); Serial.print(NH4);
|
||||||
Serial.print(" | "); Serial.print(Acetona);
|
Serial.print(" | "); Serial.print(Aceton);
|
||||||
Serial.println(" |");
|
Serial.println(" |");
|
||||||
/*
|
/*
|
||||||
Exponential regression:
|
Exponential regression:
|
||||||
@ -115,9 +115,9 @@ void loop() {
|
|||||||
CO | 605.18 | -3.937
|
CO | 605.18 | -3.937
|
||||||
Alcohol | 77.255 | -3.18
|
Alcohol | 77.255 | -3.18
|
||||||
CO2 | 110.47 | -2.862
|
CO2 | 110.47 | -2.862
|
||||||
Tolueno | 44.947 | -3.445
|
Toluen | 44.947 | -3.445
|
||||||
NH4 | 102.2 | -2.473
|
NH4 | 102.2 | -2.473
|
||||||
Acetona | 34.668 | -3.369
|
Aceton | 34.668 | -3.369
|
||||||
*/
|
*/
|
||||||
|
|
||||||
delay(500); //Sampling frequency
|
delay(500); //Sampling frequency
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
Wiring:
|
Wiring:
|
||||||
https://github.com/miguel5612/MQSensorsLib_Docs/blob/master/static/img/MQ_Arduino.PNG
|
https://github.com/miguel5612/MQSensorsLib_Docs/blob/master/static/img/MQ_Arduino.PNG
|
||||||
Please take care, arduino A0 pin represent the analog input configured on #define pin - For this example this doesn't matter
|
Please make sure arduino A0 pin represents the analog input configured on #define pin - For this example this doesn't matter
|
||||||
You will connect your sensor to your external A2D Sensor
|
You will connect your sensor to your external A2D Sensor
|
||||||
|
|
||||||
This example code is in the public domain.
|
This example code is in the public domain.
|
||||||
@ -52,7 +52,7 @@ void setup() {
|
|||||||
|
|
||||||
//Set math model to calculate the PPM concentration and the value of constants
|
//Set math model to calculate the PPM concentration and the value of constants
|
||||||
MQ3.setRegressionMethod(1); //_PPM = a*ratio^b
|
MQ3.setRegressionMethod(1); //_PPM = a*ratio^b
|
||||||
MQ3.setA(4.8387); MQ3.setB(-2.68); // Configurate the ecuation values to get Benzene concentration
|
MQ3.setA(4.8387); MQ3.setB(-2.68); // Configure the equation to to calculate Benzene concentration
|
||||||
/*
|
/*
|
||||||
Exponential regression:
|
Exponential regression:
|
||||||
Gas | a | b
|
Gas | a | b
|
||||||
@ -72,25 +72,25 @@ void setup() {
|
|||||||
|
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
// Explanation:
|
// Explanation:
|
||||||
// In this routine the sensor will measure the resistance of the sensor supposing before was pre-heated
|
// In this routine the sensor will measure the resistance of the sensor supposedly before being pre-heated
|
||||||
// and now is on clean air (Calibration conditions), and it will setup R0 value.
|
// and on clean air (Calibration conditions), setting up R0 value.
|
||||||
// We recomend execute this routine only on setup or on the laboratory and save on the eeprom of your arduino
|
// We recomend executing this routine only on setup in laboratory conditions.
|
||||||
// This routine not need to execute to every restart, you can load your R0 if you know the value
|
// This routine does not need to be executed on each restart, you can load your R0 value from eeprom.
|
||||||
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
||||||
Serial.print("Calibrating please wait.");
|
Serial.print("Calibrating please wait.");
|
||||||
float calcR0 = 0;
|
float calcR0 = 0;
|
||||||
for(int i = 1; i<=10; i ++)
|
for(int i = 1; i<=10; i ++)
|
||||||
{
|
{
|
||||||
int yourA2DValue = random(0, 1024); // 10-bit emulation
|
int yourA2DValue = random(0, 1024); // 10-bit emulation
|
||||||
MQ3.setADC(yourA2DValue);// Update data, the arduino will be read the voltage on the analog pin
|
MQ3.setADC(yourA2DValue);// Update data, the arduino will read the voltage from the analog pin
|
||||||
calcR0 += MQ3.calibrate(RatioMQ3CleanAir);
|
calcR0 += MQ3.calibrate(RatioMQ3CleanAir);
|
||||||
Serial.print(".");
|
Serial.print(".");
|
||||||
}
|
}
|
||||||
MQ3.setR0(calcR0/10);
|
MQ3.setR0(calcR0/10);
|
||||||
Serial.println(" done!.");
|
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(isinf(calcR0)) {Serial.println("Warning: Conection issue, R0 is infinite (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);}
|
if(calcR0 == 0){Serial.println("Warning: Conection issue found, R0 is zero (Analog pin shorts to ground) please check your wiring and supply"); while(1);}
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
|
|
||||||
MQ3.serialDebug(true);
|
MQ3.serialDebug(true);
|
||||||
@ -98,8 +98,8 @@ void setup() {
|
|||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
int yourA2DValue = random(0, 1024); // 10-bit emulation
|
int yourA2DValue = random(0, 1024); // 10-bit emulation
|
||||||
MQ3.setADC(yourA2DValue); // Update data, the arduino will be read the voltage on the analog pin
|
MQ3.setADC(yourA2DValue); // Update data, the arduino will read the voltage from the analog pin
|
||||||
MQ3.readSensor(); // Sensor will read PPM concentration using the model and a and b values setted before or in the setup
|
MQ3.readSensor(); // Sensor will read PPM concentration using the model, a and b values set previously or from the setup
|
||||||
MQ3.serialDebug(); // Will print the table on the serial port
|
MQ3.serialDebug(); // Will print the table on the serial port
|
||||||
delay(500); //Sampling frequency
|
delay(500); //Sampling frequency
|
||||||
}
|
}
|
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
Wiring:
|
Wiring:
|
||||||
https://github.com/miguel5612/MQSensorsLib_Docs/blob/master/static/img/MQ_Arduino.PNG
|
https://github.com/miguel5612/MQSensorsLib_Docs/blob/master/static/img/MQ_Arduino.PNG
|
||||||
Please take care, arduino A0 pin represent the analog input configured on #define pin
|
Please make sure arduino A0 pin represents the analog input configured on #define pin
|
||||||
|
|
||||||
This example code is in the public domain.
|
This example code is in the public domain.
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ void setup() {
|
|||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
//Set math model to calculate the PPM concentration and the value of constants
|
//Set math model to calculate the PPM concentration and the value of constants
|
||||||
MQ4.setRegressionMethod(1); //_PPM = a*ratio^b
|
MQ4.setRegressionMethod(1); //_PPM = a*ratio^b
|
||||||
MQ4.setA(30000000); MQ4.setB(-8.308); // Configurate the ecuation values to get CH4 concentration
|
MQ4.setA(30000000); MQ4.setB(-8.308); // Configure the equation to to calculate CH4 concentration
|
||||||
/*
|
/*
|
||||||
Exponential regression:
|
Exponential regression:
|
||||||
Gas | a | b
|
Gas | a | b
|
||||||
@ -57,24 +57,24 @@ void setup() {
|
|||||||
*/
|
*/
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
// Explanation:
|
// Explanation:
|
||||||
// In this routine the sensor will measure the resistance of the sensor supposing before was pre-heated
|
// In this routine the sensor will measure the resistance of the sensor supposedly before being pre-heated
|
||||||
// and now is on clean air (Calibration conditions), and it will setup R0 value.
|
// and on clean air (Calibration conditions), setting up R0 value.
|
||||||
// We recomend execute this routine only on setup or on the laboratory and save on the eeprom of your arduino
|
// We recomend executing this routine only on setup in laboratory conditions.
|
||||||
// This routine not need to execute to every restart, you can load your R0 if you know the value
|
// This routine does not need to be executed on each restart, you can load your R0 value from eeprom.
|
||||||
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
||||||
Serial.print("Calibrating please wait.");
|
Serial.print("Calibrating please wait.");
|
||||||
float calcR0 = 0;
|
float calcR0 = 0;
|
||||||
for(int i = 1; i<=10; i ++)
|
for(int i = 1; i<=10; i ++)
|
||||||
{
|
{
|
||||||
MQ4.update(); // Update data, the arduino will be read the voltage on the analog pin
|
MQ4.update(); // Update data, the arduino will read the voltage from the analog pin
|
||||||
calcR0 += MQ4.calibrate(RatioMQ4CleanAir);
|
calcR0 += MQ4.calibrate(RatioMQ4CleanAir);
|
||||||
Serial.print(".");
|
Serial.print(".");
|
||||||
}
|
}
|
||||||
MQ4.setR0(calcR0/10);
|
MQ4.setR0(calcR0/10);
|
||||||
Serial.println(" done!.");
|
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(isinf(calcR0)) {Serial.println("Warning: Conection issue, R0 is infinite (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);}
|
if(calcR0 == 0){Serial.println("Warning: Conection issue found, R0 is zero (Analog pin shorts to ground) please check your wiring and supply"); while(1);}
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
MQ4.serialDebug(true);
|
MQ4.serialDebug(true);
|
||||||
}
|
}
|
||||||
@ -88,7 +88,7 @@ void setup() {
|
|||||||
//Read the sensor and print in serial port
|
//Read the sensor and print in serial port
|
||||||
//Lecture will be saved in lecture variable
|
//Lecture will be saved in lecture variable
|
||||||
MQ4.update();
|
MQ4.update();
|
||||||
float smokePPM = MQ4.readSensor(); // Sensor will read PPM concentration using the model and a and b values setted before or in the setup
|
float smokePPM = MQ4.readSensor(); // Sensor will read PPM concentration using the model, a and b values set previously or from the setup
|
||||||
if(smokePPM > 1000) {Serial.println("Warning: High concentrations of smoke detected");}
|
if(smokePPM > 1000) {Serial.println("Warning: High concentrations of smoke detected");}
|
||||||
MQ4.serialDebug(); // Will print the table on the serial port
|
MQ4.serialDebug(); // Will print the table on the serial port
|
||||||
delay(400);
|
delay(400);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user