mirror of
https://github.com/miguel5612/MQSensorsLib.git
synced 2025-03-15 05:17:30 +03:00
Updated all examples, new edition V3.00
This commit is contained in:
parent
067ffa76eb
commit
a999a1815b
@ -21,9 +21,11 @@
|
||||
#define type 131 //MQ131
|
||||
|
||||
//Declare Sensor
|
||||
|
||||
MQUnifiedsensor MQ131(pin, type);
|
||||
|
||||
//Variables
|
||||
float NOx, CL2, O3;
|
||||
|
||||
void setup() {
|
||||
//init the sensor
|
||||
/***************************** MQInicializar****************************************
|
||||
@ -35,6 +37,7 @@ void setup() {
|
||||
}
|
||||
|
||||
void loop() {
|
||||
MQ131.update(); // Update data, the arduino will be read the voltaje in the analog pin
|
||||
/***************************** MQReadSensor ****************************************
|
||||
Input: Gas - Serial print flag
|
||||
Output: Value in PPM
|
||||
@ -42,9 +45,18 @@ void loop() {
|
||||
************************************************************************************/
|
||||
//Read the sensor and print in serial port
|
||||
//Lecture will be saved in lecture variable
|
||||
int lecture = MQ131.readSensor("", true); // Return O3 concentration
|
||||
//float lecture = MQ131.readSensor("", true); // Return O3 concentration
|
||||
// Options, uncomment where you need
|
||||
//int lecture = MQ131.readSensor("NOx", true); // Return NOx concentration
|
||||
//int lecture = MQ131.readSensor("CL2", true); // Return CL2 concentration
|
||||
//int lecture = MQ131.readSensor("O3", true); // Return O3 concentration
|
||||
NOx = MQ131.readSensor("NOx"); // Return NOx concentration
|
||||
CL2 = MQ131.readSensor("CL2"); // Return CL2 concentration
|
||||
O3 = MQ131.readSensor("O3"); // Return O3 concentration
|
||||
|
||||
Serial.println("***************************");
|
||||
Serial.println("Lectures for MQ-131");
|
||||
Serial.print("Volt: ");Serial.print(MQ9.getVoltage(false));Serial.println(" V");
|
||||
Serial.print("R0: ");Serial.print(MQ9.getR0());Serial.println(" Ohm");
|
||||
Serial.print("NOx: ");Serial.print(NOx,2);Serial.println(" ppm");
|
||||
Serial.print("CL2: ");Serial.print(CL2,2);Serial.println(" ppm");
|
||||
Serial.print("O3: ");Serial.print(O3,2);Serial.println(" ppm");
|
||||
Serial.println("***************************");
|
||||
}
|
||||
|
@ -21,9 +21,11 @@
|
||||
#define type 135 //MQ135
|
||||
|
||||
//Declare Sensor
|
||||
|
||||
MQUnifiedsensor MQ135(pin, type);
|
||||
|
||||
//Variables
|
||||
float CO, Alcohol, CO2, Tolueno, NH4, Acetona;
|
||||
|
||||
void setup() {
|
||||
//init the sensor
|
||||
/***************************** MQInicializar****************************************
|
||||
@ -35,6 +37,7 @@ void setup() {
|
||||
}
|
||||
|
||||
void loop() {
|
||||
MQ135.update(); // Update data, the arduino will be read the voltaje in the analog pin
|
||||
/***************************** MQReadSensor ****************************************
|
||||
Input: Gas - Serial print flag
|
||||
Output: Value in PPM
|
||||
@ -42,12 +45,24 @@ void loop() {
|
||||
************************************************************************************/
|
||||
//Read the sensor and print in serial port
|
||||
//Lecture will be saved in lecture variable
|
||||
int lecture = MQ135.readSensor("", true); // Return NH4 concentration
|
||||
//float lecture = MQ135.readSensor("", true); // Return NH4 concentration
|
||||
// Options, uncomment where you need
|
||||
//int lecture = MQ135.readSensor("CO", true); // Return CO concentration
|
||||
//int lecture = MQ135.readSensor("Alcohol", true); // Return Alcohol concentration
|
||||
//int lecture = MQ135.readSensor("CO2", true); // Return CO2 concentration
|
||||
//int lecture = MQ135.readSensor("Tolueno", true); // Return Tolueno concentration
|
||||
//int lecture = MQ135.readSensor("NH4", true); // Return NH4 concentration
|
||||
//int lecture = MQ135.readSensor("Acetona", true); // Return Acetona concentration
|
||||
CO = MQ135.readSensor("CO"); // Return CO concentration
|
||||
Alcohol = MQ135.readSensor("Alcohol"); // Return Alcohol concentration
|
||||
CO2 = MQ135.readSensor("CO2"); // Return CO2 concentration
|
||||
Tolueno = MQ135.readSensor("Tolueno"); // Return Tolueno concentration
|
||||
NH4 = MQ135.readSensor("NH4"); // Return NH4 concentration
|
||||
Acetona = MQ135.readSensor("Acetona"); // Return Acetona concentration
|
||||
|
||||
Serial.println("***************************");
|
||||
Serial.println("Lectures for MQ-135");
|
||||
Serial.print("Volt: ");Serial.print(MQ8.getVoltage(false));Serial.println(" V");
|
||||
Serial.print("R0: ");Serial.print(MQ8.getR0());Serial.println(" Ohm");
|
||||
Serial.print("CO: ");Serial.print(CO,2);Serial.println(" ppm");
|
||||
Serial.print("Alcohol: ");Serial.print(Alcohol,2);Serial.println(" ppm");
|
||||
Serial.print("CO2: ");Serial.print(CO2,2);Serial.println(" ppm");
|
||||
Serial.print("Tolueno: ");Serial.print(Tolueno,2);Serial.println(" ppm");
|
||||
Serial.print("NH4: ");Serial.print(NH4,2);Serial.println(" ppm");
|
||||
Serial.print("Acetona: ");Serial.print(Acetona,2);Serial.println(" ppm");
|
||||
Serial.println("***************************");
|
||||
}
|
||||
|
@ -23,6 +23,9 @@
|
||||
//Declare Sensor
|
||||
MQUnifiedsensor MQ2(pin, type);
|
||||
|
||||
//Variables
|
||||
float H2, LPG, CO, Alcohol, Propane, Benzene;
|
||||
|
||||
void setup() {
|
||||
//Init serial port
|
||||
Serial.begin(115200);
|
||||
@ -36,6 +39,7 @@ void setup() {
|
||||
}
|
||||
|
||||
void loop() {
|
||||
MQ2.update(); // Update data, the arduino will be read the voltaje in the analog pin
|
||||
/***************************** MQReadSensor ****************************************
|
||||
Input: Gas - Serial print flag
|
||||
Output: Value in PPM
|
||||
@ -43,13 +47,24 @@ void setup() {
|
||||
************************************************************************************/
|
||||
//Read the sensor and print in serial port
|
||||
//Lecture will be saved in lecture variable
|
||||
int lecture = MQ2.readSensor("", true); // Return LPG concentration
|
||||
//float lecture = MQ2.readSensor("", true); // Return LPG concentration
|
||||
// Options, uncomment where you need
|
||||
//int lecture = MQ2.readSensor("H2", true); // Return H2 concentration
|
||||
//int lecture = MQ2.readSensor("LPG", true); // Return LPG concentration
|
||||
//int lecture = MQ2.readSensor("CO", true); // Return CO concentration
|
||||
//int lecture = MQ2.readSensor("Alcohol", true); // Return Alcohol concentration
|
||||
//int lecture = MQ2.readSensor("Propane", true); // Return Propane concentration
|
||||
//int lecture = MQ2.readSensor("Benzene", true); // Return Benzene concentration
|
||||
delay(400);
|
||||
H2 = MQ2.readSensor("H2"); // Return H2 concentration
|
||||
LPG = MQ2.readSensor("LPG"); // Return LPG concentration
|
||||
CO = MQ2.readSensor("CO"); // Return CO concentration
|
||||
Alcohol = MQ2.readSensor("Alcohol"); // Return Alcohol concentration
|
||||
Propane = MQ2.readSensor("Propane"); // Return Propane concentration
|
||||
Benzene = MQ2.readSensor("Benzene"); // Return Benzene concentration
|
||||
|
||||
Serial.println("***************************");
|
||||
Serial.println("Lectures for MQ-2");
|
||||
Serial.print("Volt: ");Serial.print(MQ2.getVoltage(false));Serial.println(" V");
|
||||
Serial.print("R0: ");Serial.print(MQ2.getR0());Serial.println(" Ohm");
|
||||
Serial.print("H2: ");Serial.print(H2,2);Serial.println(" ppm");
|
||||
Serial.print("LPG: ");Serial.print(LPG,2);Serial.println(" ppm");
|
||||
Serial.print("CO: ");Serial.print(CO,2);Serial.println(" ppm");
|
||||
Serial.print("Alcohol: ");Serial.print(Alcohol,2);Serial.println(" ppm");
|
||||
Serial.print("Propane: ");Serial.print(Propane,2);Serial.println(" ppm");
|
||||
Serial.print("Benzene: ");Serial.print(Benzene,2);Serial.println(" ppm");
|
||||
Serial.println("***************************");
|
||||
}
|
||||
|
@ -21,9 +21,11 @@
|
||||
#define type 303 //MQ303
|
||||
|
||||
//Declare Sensor
|
||||
|
||||
MQUnifiedsensor MQ303(pin, type);
|
||||
|
||||
//Variables
|
||||
float Iso_butano, Hydrogeno, Ethanol;
|
||||
|
||||
void setup() {
|
||||
//init the sensor
|
||||
/***************************** MQInicializar****************************************
|
||||
@ -35,6 +37,7 @@ void setup() {
|
||||
}
|
||||
|
||||
void loop() {
|
||||
MQ303.update();
|
||||
/***************************** MQReadSensor ****************************************
|
||||
Input: Gas - Serial print flag
|
||||
Output: Value in PPM
|
||||
@ -42,10 +45,19 @@ void loop() {
|
||||
************************************************************************************/
|
||||
//Read the sensor and print in serial port
|
||||
//Lecture will be saved in lecture variable
|
||||
int lecture = MQ303.readSensor("", true); // Return Isobutano concentration
|
||||
//float lecture = MQ303.readSensor("", true); // Return Isobutano concentration
|
||||
// Options, uncomment where you need
|
||||
//int lecture = MQ303.readSensor("Iso_butano", true); // Return Iso_butano concentration
|
||||
//int lecture = MQ303.readSensor("Hydrogeno", true); // Return Hydrogeno concentration
|
||||
//int lecture = MQ303.readSensor("Ethanol", true); // Return Ethanol concentration
|
||||
delay(400);
|
||||
Iso_butano = MQ303.readSensor("Iso_butano"); // Return Iso_butano concentration
|
||||
Hydrogeno = MQ303.readSensor("Hydrogeno"); // Return Hydrogeno concentration
|
||||
Ethanol = MQ303.readSensor("Ethanol"); // Return Ethanol concentration
|
||||
|
||||
Serial.println("***************************");
|
||||
Serial.println("Lectures for MQ-135");
|
||||
Serial.print("Volt: ");Serial.print(MQ8.getVoltage(false));Serial.println(" V");
|
||||
Serial.print("R0: ");Serial.print(MQ8.getR0());Serial.println(" Ohm");
|
||||
Serial.print("Iso_butano: ");Serial.print(Iso_butano,2);Serial.println(" ppm");
|
||||
Serial.print("Hydrogeno: ");Serial.print(Hydrogeno,2);Serial.println(" ppm");
|
||||
Serial.print("Ethanol: ");Serial.print(Ethanol,2);Serial.println(" ppm");
|
||||
Serial.println("***************************");
|
||||
|
||||
}
|
||||
|
@ -21,9 +21,11 @@
|
||||
#define type 4 //MQ4
|
||||
|
||||
//Declare Sensor
|
||||
|
||||
MQUnifiedsensor MQ4(pin, type);
|
||||
|
||||
//Variables
|
||||
float CH4, LPG, CO, Alcohol, smoke;
|
||||
|
||||
void setup() {
|
||||
//init the sensor
|
||||
/***************************** MQInicializar****************************************
|
||||
@ -35,6 +37,7 @@ void setup() {
|
||||
}
|
||||
|
||||
void loop() {
|
||||
MQ4.update(); // Update data, the arduino will be read the voltaje in the analog pin
|
||||
/***************************** MQReadSensor ****************************************
|
||||
Input: Gas - Serial print flag
|
||||
Output: Value in PPM
|
||||
@ -42,12 +45,22 @@ void loop() {
|
||||
************************************************************************************/
|
||||
//Read the sensor and print in serial port
|
||||
//Lecture will be saved in lecture variable
|
||||
int lecture = MQ4.readSensor("", true); // Return CH4 concentration
|
||||
//float lecture = MQ4.readSensor("", true); // Return CH4 concentration
|
||||
// Options, uncomment where you need
|
||||
//int lecture = MQ4.readSensor("CH4", true); // Return CH4 concentration
|
||||
//int lecture = MQ4.readSensor("LPG", true); // Return LPG concentration
|
||||
//int lecture = MQ4.readSensor("CO", true); // Return CO concentration
|
||||
//int lecture = MQ4.readSensor("Alcohol", true); // Return Alcohol concentration
|
||||
//int lecture = MQ4.readSensor("smoke", true); // Return smoke concentration
|
||||
delay(400);
|
||||
CH4 = MQ4.readSensor("CH4"); // Return CH4 concentration
|
||||
LPG = MQ4.readSensor("LPG"); // Return LPG concentration
|
||||
CO = MQ4.readSensor("CO"); // Return CO concentration
|
||||
Alcohol = MQ4.readSensor("Alcohol"); // Return Alcohol concentration
|
||||
smoke = MQ4.readSensor("smoke"); // Return smoke concentration
|
||||
|
||||
Serial.println("***************************");
|
||||
Serial.println("Lectures for MQ-4");
|
||||
Serial.print("Volt: ");Serial.print(MQ4.getVoltage(false));Serial.println(" V");
|
||||
Serial.print("R0: ");Serial.print(MQ4.getR0());Serial.println(" Ohm");
|
||||
Serial.print("CH4: ");Serial.print(CH4,2);Serial.println(" ppm");
|
||||
Serial.print("LPG: ");Serial.print(LPG,2);Serial.println(" ppm");
|
||||
Serial.print("CO: ");Serial.print(CO,2);Serial.println(" ppm");
|
||||
Serial.print("Alcohol: ");Serial.print(Alcohol,2);Serial.println(" ppm");
|
||||
Serial.print("smoke: ");Serial.print(smoke,2);Serial.println(" ppm");
|
||||
Serial.println("***************************");
|
||||
}
|
||||
|
@ -18,12 +18,14 @@
|
||||
|
||||
//Definitions
|
||||
#define pin A0 //Analog input 0 of your arduino
|
||||
#define type 5 //MQ4
|
||||
#define type 5 //MQ5
|
||||
|
||||
//Declare Sensor
|
||||
|
||||
MQUnifiedsensor MQ5(pin, type);
|
||||
|
||||
//Variables
|
||||
float H2, LPG, CH4, CO, smoke;
|
||||
|
||||
void setup() {
|
||||
//init the sensor
|
||||
/***************************** MQInicializar****************************************
|
||||
@ -35,6 +37,8 @@ void setup() {
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
MQ5.update(); // Update data, the arduino will be read the voltaje in the analog pin
|
||||
/***************************** MQReadSensor ****************************************
|
||||
Input: Gas - Serial print flag
|
||||
Output: Value in PPM
|
||||
@ -42,12 +46,22 @@ void loop() {
|
||||
************************************************************************************/
|
||||
//Read the sensor and print in serial port
|
||||
//Lecture will be saved in lecture variable
|
||||
int lecture = MQ5.readSensor("", true); // Return H2 concentration
|
||||
//float lecture = MQ5.readSensor("", true); // Return H2 concentration
|
||||
// Options, uncomment where you need
|
||||
//int lecture = MQ5.readSensor("H2", true); // Return H2 concentration
|
||||
//int lecture = MQ5.readSensor("LPG", true); // Return LPG concentration
|
||||
//int lecture = MQ5.readSensor("CH4", true); // Return CH4 concentration
|
||||
//int lecture = MQ5.readSensor("CO", true); // Return CO concentration
|
||||
//int lecture = MQ5.readSensor("smoke", true); // Return smoke concentration
|
||||
delay(400);
|
||||
H2 = MQ5.readSensor("H2"); // Return H2 concentration
|
||||
LPG = MQ5.readSensor("LPG"); // Return LPG concentration
|
||||
CH4 = MQ5.readSensor("CH4"); // Return CH4 concentration
|
||||
CO = MQ5.readSensor("CO"); // Return CO concentration
|
||||
smoke = MQ5.readSensor("smoke"); // Return smoke concentration
|
||||
|
||||
Serial.println("***************************");
|
||||
Serial.println("Lectures for MQ-5");
|
||||
Serial.print("Volt: ");Serial.print(MQ5.getVoltage(false));Serial.println(" V");
|
||||
Serial.print("R0: ");Serial.print(MQ5.getR0());Serial.println(" Ohm");
|
||||
Serial.print("H2: ");Serial.print(H2,2);Serial.println(" ppm");
|
||||
Serial.print("LPG: ");Serial.print(LPG,2);Serial.println(" ppm");
|
||||
Serial.print("CH4: ");Serial.print(CH4,2);Serial.println(" ppm");
|
||||
Serial.print("CO: ");Serial.print(CO,2);Serial.println(" ppm");
|
||||
Serial.print("smoke: ");Serial.print(smoke,2);Serial.println(" ppm");
|
||||
Serial.println("***************************");
|
||||
}
|
||||
|
@ -18,12 +18,14 @@
|
||||
|
||||
//Definitions
|
||||
#define pin A0 //Analog input 0 of your arduino
|
||||
#define type 6 //MQ4
|
||||
#define type 6 //MQ6
|
||||
|
||||
//Declare Sensor
|
||||
|
||||
MQUnifiedsensor MQ6(pin, type);
|
||||
|
||||
//Variables
|
||||
float H2, LPG, CH4, CO, Alcohol;
|
||||
|
||||
void setup() {
|
||||
//init the sensor
|
||||
/***************************** MQInicializar****************************************
|
||||
@ -35,6 +37,7 @@ void setup() {
|
||||
}
|
||||
|
||||
void loop() {
|
||||
MQ6.update(); // Update data, the arduino will be read the voltaje in the analog pin
|
||||
/***************************** MQReadSensor ****************************************
|
||||
Input: Gas - Serial print flag
|
||||
Output: Value in PPM
|
||||
@ -42,11 +45,22 @@ void loop() {
|
||||
************************************************************************************/
|
||||
//Read the sensor and print in serial port
|
||||
//Lecture will be saved in lecture variable
|
||||
int lecture = MQ6.readSensor("", true); // Return CH4 concentration
|
||||
//float lecture = MQ6.readSensor("", true); // Return CH4 concentration
|
||||
// Options, uncomment where you need
|
||||
//int lecture = MQ6.readSensor("H2", true); // Return H2 concentration
|
||||
//int lecture = MQ6.readSensor("LPG", true); // Return LPG concentration
|
||||
//int lecture = MQ6.readSensor("CH4", true); // Return CH4 concentration
|
||||
//int lecture = MQ6.readSensor("CO", true); // Return CO concentration
|
||||
//int lecture = MQ6.readSensor("Alcohol", true); // Return Alcohol concentration
|
||||
H2 = MQ6.readSensor("H2"); // Return H2 concentration
|
||||
LPG = MQ6.readSensor("LPG"); // Return LPG concentration
|
||||
CH4 = MQ6.readSensor("CH4"); // Return CH4 concentration
|
||||
CO = MQ6.readSensor("CO"); // Return CO concentration
|
||||
Alcohol = MQ6.readSensor("Alcohol"); // Return Alcohol concentration
|
||||
|
||||
Serial.println("***************************");
|
||||
Serial.println("Lectures for MQ-6");
|
||||
Serial.print("Volt: ");Serial.print(MQ6.getVoltage(false));Serial.println(" V");
|
||||
Serial.print("R0: ");Serial.print(MQ6.getR0());Serial.println(" Ohm");
|
||||
Serial.print("H2: ");Serial.print(H2,2);Serial.println(" ppm");
|
||||
Serial.print("LPG: ");Serial.print(LPG,2);Serial.println(" ppm");
|
||||
Serial.print("CH4: ");Serial.print(CH4,2);Serial.println(" ppm");
|
||||
Serial.print("CO: ");Serial.print(CO,2);Serial.println(" ppm");
|
||||
Serial.print("Alcohol: ");Serial.print(Alcohol,2);Serial.println(" ppm");
|
||||
Serial.println("***************************");
|
||||
}
|
||||
|
@ -24,9 +24,11 @@
|
||||
|
||||
|
||||
//Declare Sensor
|
||||
|
||||
MQUnifiedsensor MQ7(pin, type);
|
||||
|
||||
//Variables
|
||||
float H2, LPG, CH4, CO, Alcohol;
|
||||
|
||||
void setup() {
|
||||
//init the sensor
|
||||
/***************************** MQInicializar****************************************
|
||||
@ -38,6 +40,7 @@ void setup() {
|
||||
}
|
||||
|
||||
void loop() {
|
||||
MQ7.update(); // Update data, the arduino will be read the voltaje in the analog pin
|
||||
/***************************** MQReadSensor ****************************************
|
||||
Input: Gas - Serial print flag
|
||||
Output: Value in PPM
|
||||
@ -45,12 +48,22 @@ void loop() {
|
||||
************************************************************************************/
|
||||
//Read the sensor and print in serial port
|
||||
//Lecture will be saved in lecture variable
|
||||
int lecture = MQ7.readSensor("", true); // Return CH4 concentration
|
||||
//float lecture = MQ7.readSensor("", true); // Return CH4 concentration
|
||||
// Options, uncomment where you need
|
||||
//int lecture = MQ7.readSensor("H2", true); // Return CH4 concentration
|
||||
//int lecture = MQ7.readSensor("LPG", true); // Return LPG concentration
|
||||
//int lecture = MQ7.readSensor("CH4", true); // Return CH4 concentration
|
||||
//int lecture = MQ7.readSensor("CO", true); // Return CO concentration
|
||||
//int lecture = MQ7.readSensor("Alcohol", true); // Return Alcohol concentration
|
||||
delay(400);
|
||||
H2 = MQ7.readSensor("H2"); // Return CH4 concentration
|
||||
LPG = MQ7.readSensor("LPG"); // Return LPG concentration
|
||||
CH4 = MQ7.readSensor("CH4"); // Return CH4 concentration
|
||||
CO = MQ7.readSensor("CO"); // Return CO concentration
|
||||
Alcohol = MQ7.readSensor("Alcohol"); // Return Alcohol concentration
|
||||
|
||||
Serial.println("***************************");
|
||||
Serial.println("Lectures for MQ-7");
|
||||
Serial.print("Volt: ");Serial.print(MQ7.getVoltage(false));Serial.println(" V");
|
||||
Serial.print("R0: ");Serial.print(MQ7.getR0());Serial.println(" Ohm");
|
||||
Serial.print("H2: ");Serial.print(H2,2);Serial.println(" ppm");
|
||||
Serial.print("LPG: ");Serial.print(LPG,2);Serial.println(" ppm");
|
||||
Serial.print("CH4: ");Serial.print(CH4,2);Serial.println(" ppm");
|
||||
Serial.print("CO: ");Serial.print(CO,2);Serial.println(" ppm");
|
||||
Serial.print("Alcohol: ");Serial.print(Alcohol,2);Serial.println(" ppm");
|
||||
Serial.println("***************************");
|
||||
}
|
||||
|
@ -21,9 +21,11 @@
|
||||
#define type 8 //MQ8
|
||||
|
||||
//Declare Sensor
|
||||
|
||||
MQUnifiedsensor MQ8(pin, type);
|
||||
|
||||
//Variables
|
||||
float H2, LPG, CH4, CO, Alcohol;
|
||||
|
||||
void setup() {
|
||||
//init the sensor
|
||||
/***************************** MQInicializar****************************************
|
||||
@ -35,6 +37,7 @@ void setup() {
|
||||
}
|
||||
|
||||
void loop() {
|
||||
MQ8.update(); // Update data, the arduino will be read the voltaje in the analog pin
|
||||
/***************************** MQReadSensor ****************************************
|
||||
Input: Gas - Serial print flag
|
||||
Output: Value in PPM
|
||||
@ -42,12 +45,22 @@ void loop() {
|
||||
************************************************************************************/
|
||||
//Read the sensor and print in serial port
|
||||
//Lecture will be saved in lecture variable
|
||||
int lecture = MQ8.readSensor("", true); // Return H2 concentration
|
||||
//float lecture = MQ8.readSensor("", true); // Return H2 concentration
|
||||
// Options, uncomment where you need
|
||||
//int lecture = MQ8.readSensor("H2", true); // Return CH4 concentration
|
||||
//int lecture = MQ8.readSensor("LPG", true); // Return LPG concentration
|
||||
//int lecture = MQ8.readSensor("CH4", true); // Return CH4 concentration
|
||||
//int lecture = MQ8.readSensor("CO", true); // Return CO concentration
|
||||
//int lecture = MQ8.readSensor("Alcohol", true); // Return Alcohol concentration
|
||||
delay(400);
|
||||
H2 = MQ8.readSensor("H2"); // Return CH4 concentration
|
||||
LPG = MQ8.readSensor("LPG"); // Return LPG concentration
|
||||
CH4 = MQ8.readSensor("CH4"); // Return CH4 concentration
|
||||
CO = MQ8.readSensor("CO"); // Return CO concentration
|
||||
Alcohol = MQ8.readSensor("Alcohol"); // Return Alcohol concentration
|
||||
|
||||
Serial.println("***************************");
|
||||
Serial.println("Lectures for MQ-8");
|
||||
Serial.print("Volt: ");Serial.print(MQ8.getVoltage(false));Serial.println(" V");
|
||||
Serial.print("R0: ");Serial.print(MQ8.getR0());Serial.println(" Ohm");
|
||||
Serial.print("H2: ");Serial.print(H2,2);Serial.println(" ppm");
|
||||
Serial.print("LPG: ");Serial.print(LPG,2);Serial.println(" ppm");
|
||||
Serial.print("CH4: ");Serial.print(CH4,2);Serial.println(" ppm");
|
||||
Serial.print("CO: ");Serial.print(CO,2);Serial.println(" ppm");
|
||||
Serial.print("Alcohol: ");Serial.print(Alcohol,2);Serial.println(" ppm");
|
||||
Serial.println("***************************");
|
||||
}
|
||||
|
@ -21,9 +21,11 @@
|
||||
#define type 9 //MQ9
|
||||
|
||||
//Declare Sensor
|
||||
|
||||
MQUnifiedsensor MQ9(pin, type);
|
||||
|
||||
//Variables
|
||||
float CO, CH4, LPG;
|
||||
|
||||
void setup() {
|
||||
//init the sensor
|
||||
/***************************** MQInicializar****************************************
|
||||
@ -35,6 +37,7 @@ void setup() {
|
||||
}
|
||||
|
||||
void loop() {
|
||||
MQ9.update(); // Update data, the arduino will be read the voltaje in the analog pin
|
||||
/***************************** MQReadSensor ****************************************
|
||||
Input: Gas - Serial print flag
|
||||
Output: Value in PPM
|
||||
@ -42,10 +45,18 @@ void loop() {
|
||||
************************************************************************************/
|
||||
//Read the sensor and print in serial port
|
||||
//Lecture will be saved in lecture variable
|
||||
int lecture = MQ8.readSensor("", true); // Return LPG concentration
|
||||
//float lecture = MQ9.readSensor("", true); // Return LPG concentration
|
||||
// Options, uncomment where you need
|
||||
//int lecture = MQ8.readSensor("LPG", true); // Return LPG concentration
|
||||
//int lecture = MQ8.readSensor("CH4", true); // Return CH4 concentration
|
||||
//int lecture = MQ8.readSensor("CO", true); // Return CO concentration
|
||||
delay(400);
|
||||
LPG = MQ9.readSensor("LPG"); // Return LPG concentration
|
||||
CH4 = MQ9.readSensor("CH4"); // Return CH4 concentration
|
||||
CO = MQ9.readSensor("CO"); // Return CO concentration
|
||||
|
||||
Serial.println("***************************");
|
||||
Serial.println("Lectures for MQ-9");
|
||||
Serial.print("Volt: ");Serial.print(MQ9.getVoltage(false));Serial.println(" V");
|
||||
Serial.print("R0: ");Serial.print(MQ9.getR0());Serial.println(" Ohm");
|
||||
Serial.print("CO: ");Serial.print(CO,2);Serial.println(" ppm");
|
||||
Serial.print("LPG: ");Serial.print(LPG,2);Serial.println(" ppm");
|
||||
Serial.print("CH4: ");Serial.print(CH4,2);Serial.println(" ppm");
|
||||
Serial.println("***************************");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user