mirror of
https://github.com/miguel5612/MQSensorsLib.git
synced 2025-07-03 19:01:03 +03:00
Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
d0b00b4025 | |||
f83e0fb0d7 | |||
65a1246e51 | |||
28ce4c80f7 | |||
9497574e11 | |||
9cbc753758 | |||
c7b67d7fa5 | |||
6b3c764b71 |
@ -23,18 +23,18 @@
|
|||||||
|
|
||||||
//Include the library
|
//Include the library
|
||||||
#include <MQUnifiedsensor.h>
|
#include <MQUnifiedsensor.h>
|
||||||
|
/************************Hardware Related Macros************************************/
|
||||||
|
#define Board ("Arduino UNO")
|
||||||
|
#define Pin (A3) //Analog input 3 of your arduino
|
||||||
|
/***********************Software Related Macros************************************/
|
||||||
|
#define Type ("MQ-3") //MQ3
|
||||||
|
#define Voltage_Resolution (5)
|
||||||
|
#define ADC_Bit_Resolution (10) // For arduino UNO/MEGA/NANO
|
||||||
|
|
||||||
//Definitions
|
/*****************************Globals***********************************************/
|
||||||
#define placa "Arduino UNO"
|
double alcoholPPM = (0);
|
||||||
#define Voltage_Resolution 5
|
/**************************Object_Sensor********************************************/
|
||||||
#define pin A3 //Analog input 3 of your arduino
|
MQUnifiedsensor MQ3(Board, Voltage_Resolution, ADC_Bit_Resolution, Pin, Type);
|
||||||
#define type "MQ-3" //MQ3
|
|
||||||
#define ADC_Bit_Resolution 10 // For arduino UNO/MEGA/NANO
|
|
||||||
//#define calibration_button 13 //Pin to calibrate your sensor
|
|
||||||
|
|
||||||
double alcoholPPM = 0;
|
|
||||||
//Declare Sensor
|
|
||||||
MQUnifiedsensor MQ3(placa, Voltage_Resolution, ADC_Bit_Resolution, pin, type);
|
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
//Init the serial port communication - to debug the library
|
//Init the serial port communication - to debug the library
|
||||||
@ -54,18 +54,35 @@ void setup() {
|
|||||||
Hexane | 7585.3 | -2.849
|
Hexane | 7585.3 | -2.849
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Calibration setup
|
|
||||||
MQ3.setR0(3.86018237);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
//If the RL value is different from 10K please assign your RL value with the following method:
|
//If the RL value is different from 10K please assign your RL value with the following method:
|
||||||
MQ3.setRL(10);
|
MQ3.setRL(10);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/***************************** MQ Init ********************************************/
|
/***************************** MQ Init ********************************************/
|
||||||
//Remarks: Configure the pin of arduino as input.
|
//Remarks: Configure the pin of arduino as input.
|
||||||
/************************************************************************************/
|
/************************************************************************************/
|
||||||
MQ3.init();
|
MQ3.init();
|
||||||
|
/***************************** MQ CAlibration ********************************************/
|
||||||
|
// Explanation:
|
||||||
|
// In this routine the sensor will measure the resistance of the sensor supposing before was pre-heated
|
||||||
|
// and now is on clean air (Calibration conditions), and it will setup R0 value.
|
||||||
|
// We recomend execute this routine only on setup or on the laboratory and save on the eeprom of your arduino
|
||||||
|
// This routine not need to execute to every restart, you can load your R0 if you know the value
|
||||||
|
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
||||||
|
Serial.print("Calibrating please wait.");
|
||||||
|
float calcR0 = 0;
|
||||||
|
for(int i = 1; i<=10; i ++)
|
||||||
|
{
|
||||||
|
MQ3.update(); // Update data, the arduino will be read the voltage on the analog pin
|
||||||
|
calcR0 += MQ3.calibrate(RatioMQ3CleanAir);
|
||||||
|
Serial.print(".");
|
||||||
|
}
|
||||||
|
MQ3.setR0(calcR0/10);
|
||||||
|
Serial.println(" done!.");
|
||||||
|
|
||||||
|
if(isinf(calcR0)) {Serial.println("Warning: Conection issue founded, R0 is infite (Open circuit detected) please check your wiring and supply"); while(1);}
|
||||||
|
if(calcR0 == 0){Serial.println("Warning: Conection issue founded, R0 is zero (Analog pin with short circuit to ground) please check your wiring and supply"); while(1);}
|
||||||
|
/***************************** MQ CAlibration ********************************************/
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
|
@ -13,20 +13,25 @@
|
|||||||
with which the library was made.
|
with which the library was made.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//Definitions
|
//Include the library
|
||||||
#define placa "Arduino Mega 2560"
|
#include <MQUnifiedsensor.h>
|
||||||
#define Voltage_Resolution 5
|
/************************Hardware Related Macros************************************/
|
||||||
#define type "Algorithm Tester"
|
#define Board ("Arduino UNO")
|
||||||
#define ADC_Bit_Resolution 10 // For arduino UNO/MEGA/NANO
|
#define Pin (A3) //Analog input 3 of your arduino
|
||||||
// On this program pin value doesn't matter
|
/***********************Software Related Macros************************************/
|
||||||
#define pin2 A2 //Analog input 2 of your arduino
|
#define Type ("MQ-3") //MQ3
|
||||||
//Declare Sensor
|
#define Voltage_Resolution (5)
|
||||||
MQUnifiedsensor mySensor(placa, Voltage_Resolution, ADC_Bit_Resolution, pin2, type);
|
#define ADC_Bit_Resolution (10) // For arduino UNO/MEGA/NANO
|
||||||
|
|
||||||
|
//Declare Sensor
|
||||||
|
MQUnifiedsensor mySensor(Board, Voltage_Resolution, ADC_Bit_Resolution, Pin, Type);
|
||||||
|
|
||||||
|
/*****************************Globals***********************************************/
|
||||||
double ratio[4] = {};
|
double ratio[4] = {};
|
||||||
double expectedValue[4] = {};
|
double expectedValue[4] = {};
|
||||||
double calculatedValues[4] = {};
|
double calculatedValues[4] = {};
|
||||||
double error[4] = {};
|
double error[4] = {};
|
||||||
|
/**************************Object_Sensor********************************************/
|
||||||
|
|
||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
|
@ -15,15 +15,16 @@
|
|||||||
|
|
||||||
//Include the library
|
//Include the library
|
||||||
#include <MQUnifiedsensor.h>
|
#include <MQUnifiedsensor.h>
|
||||||
|
/************************Hardware Related Macros************************************/
|
||||||
|
#define Board ("Arduino UNO")
|
||||||
|
#define Pin (A2) //Analog input 2 of your arduino
|
||||||
|
/***********************Software Related Macros************************************/
|
||||||
|
#define Type ("MQ-2") //MQ2
|
||||||
|
#define Voltage_Resolution (5)
|
||||||
|
#define ADC_Bit_Resolution (10) // For arduino UNO/MEGA/NANO
|
||||||
|
|
||||||
//Definitions
|
/*****************************Globals***********************************************/
|
||||||
#define placa "Arduino UNO"
|
double alcoholPPM = (0);
|
||||||
#define Voltage_Resolution 5
|
|
||||||
#define pin A2 //Analog input 2 of your arduino
|
|
||||||
#define type "MQ-2" //MQ2
|
|
||||||
#define ADC_Bit_Resolution 10 // For arduino UNO/MEGA/NANO
|
|
||||||
|
|
||||||
|
|
||||||
//Defaults, uncomment if you need
|
//Defaults, uncomment if you need
|
||||||
#define RatioMQ2CleanAir 9.83 //RS / R0 = 9.83 ppm
|
#define RatioMQ2CleanAir 9.83 //RS / R0 = 9.83 ppm
|
||||||
//#define RatioMQ3CleanAir 60 //RS / R0 = 60 ppm
|
//#define RatioMQ3CleanAir 60 //RS / R0 = 60 ppm
|
||||||
@ -37,17 +38,20 @@
|
|||||||
//#define RatioMQ135CleanAir 3.6//RS / R0 = 3.6 ppm
|
//#define RatioMQ135CleanAir 3.6//RS / R0 = 3.6 ppm
|
||||||
//#define RatioMQ303CleanAir 1 //RS / R0 = 1 ppm
|
//#define RatioMQ303CleanAir 1 //RS / R0 = 1 ppm
|
||||||
//#define RatioMQ309CleanAir 11 //RS / R0 = 11 ppm
|
//#define RatioMQ309CleanAir 11 //RS / R0 = 11 ppm
|
||||||
|
|
||||||
//Declare Sensor
|
|
||||||
|
|
||||||
MQUnifiedsensor MQ2(placa, Voltage_Resolution, ADC_Bit_Resolution, pin, type);
|
|
||||||
unsigned long contador = 0;
|
unsigned long contador = 0;
|
||||||
|
/**************************Object_Sensor********************************************/
|
||||||
|
|
||||||
|
MQUnifiedsensor MQ2(Board, Voltage_Resolution, ADC_Bit_Resolution, Pin, Type);
|
||||||
|
|
||||||
void setup() {
|
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); // Configurate the ecuation values to get LPG concentration
|
||||||
|
/*
|
||||||
|
//If the RL value is different from 10K please assign your RL value with the following method:
|
||||||
|
MQ3.setRL(10);
|
||||||
|
*/
|
||||||
//init the sensor
|
//init the sensor
|
||||||
MQ2.init();
|
MQ2.init();
|
||||||
//Print in serial monitor
|
//Print in serial monitor
|
||||||
|
@ -22,16 +22,17 @@
|
|||||||
|
|
||||||
//Include the library
|
//Include the library
|
||||||
#include <MQUnifiedsensor.h>
|
#include <MQUnifiedsensor.h>
|
||||||
|
/************************Hardware Related Macros************************************/
|
||||||
//Definitions
|
#define Board ("Arduino UNO")
|
||||||
#define placa "ESP8266" //NodeMcu, WeMos D1, TTGo, ESP32.. etc
|
#define Pin (A0) //Analog input 3 of your arduino
|
||||||
#define Voltage_Resolution 3.3
|
/***********************Software Related Macros************************************/
|
||||||
#define pin A0 //Analog input 0 of your ESP Board
|
#define Type ("MQ-3") //MQ3
|
||||||
#define type "MQ-3" //MQ3
|
#define Voltage_Resolution (3.3) // 3V3 <- IMPORTANT
|
||||||
#define ADC_Bit_Resolution 10 // For ESP8266
|
#define ADC_Bit_Resolution (10) // For arduino UNO/MEGA/NANO
|
||||||
|
#define RatioMQ3CleanAir (60)
|
||||||
//Declare Sensor
|
/*****************************Globals***********************************************/
|
||||||
MQUnifiedsensor MQ3(placa, Voltage_Resolution, ADC_Bit_Resolution, pin, type);
|
MQUnifiedsensor MQ3(Board, Voltage_Resolution, ADC_Bit_Resolution, Pin, Type);
|
||||||
|
/*****************************Globals***********************************************/
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
//Init the serial port communication - to debug the library
|
//Init the serial port communication - to debug the library
|
||||||
@ -51,23 +52,36 @@ void setup() {
|
|||||||
Hexane | 7585.3 | -2.849
|
Hexane | 7585.3 | -2.849
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Calibration setup
|
/***************************** MQ Init ********************************************/
|
||||||
MQ3.setR0(3.86018237);
|
//Remarks: Configure the pin of arduino as input.
|
||||||
|
/************************************************************************************/
|
||||||
|
MQ3.init();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
//If the RL value is different from 10K please assign your RL value with the following method:
|
//If the RL value is different from 10K please assign your RL value with the following method:
|
||||||
MQ3.setRL(10);
|
MQ3.setRL(10);
|
||||||
*/
|
*/
|
||||||
|
/***************************** MQ CAlibration ********************************************/
|
||||||
|
// Explanation:
|
||||||
|
// In this routine the sensor will measure the resistance of the sensor supposing before was pre-heated
|
||||||
|
// and now is on clean air (Calibration conditions), and it will setup R0 value.
|
||||||
|
// We recomend execute this routine only on setup or on the laboratory and save on the eeprom of your arduino
|
||||||
|
// This routine not need to execute to every restart, you can load your R0 if you know the value
|
||||||
|
// Acknowledgements: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
||||||
|
Serial.print("Calibrating please wait.");
|
||||||
|
float calcR0 = 0;
|
||||||
|
for(int i = 1; i<=10; i ++)
|
||||||
|
{
|
||||||
|
MQ3.update(); // Update data, the arduino will be read the voltage on the analog pin
|
||||||
|
calcR0 += MQ3.calibrate(RatioMQ3CleanAir);
|
||||||
|
Serial.print(".");
|
||||||
|
}
|
||||||
|
MQ3.setR0(calcR0/10);
|
||||||
|
Serial.println(" done!.");
|
||||||
|
|
||||||
/***************************** MQ Init ********************************************/
|
if(isinf(calcR0)) {Serial.println("Warning: Conection issue founded, R0 is infite (Open circuit detected) please check your wiring and supply"); while(1);}
|
||||||
//Remarks: Configure the pin of arduino as input.
|
if(calcR0 == 0){Serial.println("Warning: Conection issue founded, R0 is zero (Analog pin with short circuit to ground) please check your wiring and supply"); while(1);}
|
||||||
/************************************************************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
MQ3.init();
|
|
||||||
/***************************** MQ Init ********************************************/
|
|
||||||
//Input: setup flag, if this function are on setup will print the headers (Optional - Default value: False)
|
|
||||||
//Output: print on serial port the information about sensor and sensor readings
|
|
||||||
//Remarks: Configure the pin of arduino as input.
|
|
||||||
/************************************************************************************/
|
|
||||||
MQ3.serialDebug(true);
|
MQ3.serialDebug(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,6 +53,14 @@ void setup() {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/***************************** MQ Init ********************************************/
|
||||||
|
//Remarks: Configure the pin of arduino as input.
|
||||||
|
/************************************************************************************/
|
||||||
|
MQ131.init();
|
||||||
|
/*
|
||||||
|
//If the RL value is different from 10K please assign your RL value with the following method:
|
||||||
|
MQ131.setRL(10);
|
||||||
|
*/
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** 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 supposing before was pre-heated
|
||||||
@ -74,21 +82,6 @@ void setup() {
|
|||||||
if(isinf(calcR0)) {Serial.println("Warning: Conection issue founded, R0 is infite (Open circuit detected) please check your wiring and supply"); while(1);}
|
if(isinf(calcR0)) {Serial.println("Warning: Conection issue founded, R0 is infite (Open circuit detected) please check your wiring and supply"); while(1);}
|
||||||
if(calcR0 == 0){Serial.println("Warning: Conection issue founded, R0 is zero (Analog pin with short circuit to ground) please check your wiring and supply"); while(1);}
|
if(calcR0 == 0){Serial.println("Warning: Conection issue founded, R0 is zero (Analog pin with short circuit to ground) please check your wiring and supply"); while(1);}
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
|
|
||||||
/*
|
|
||||||
//If the RL value is different from 10K please assign your RL value with the following method:
|
|
||||||
MQ131.setRL(10);
|
|
||||||
*/
|
|
||||||
|
|
||||||
/***************************** MQ Init ********************************************/
|
|
||||||
//Remarks: Configure the pin of arduino as input.
|
|
||||||
/************************************************************************************/
|
|
||||||
MQ131.init();
|
|
||||||
/***************************** MQ Init ********************************************/
|
|
||||||
//Input: setup flag, if this function are on setup will print the headers (Optional - Default value: False)
|
|
||||||
//Output: print on serial port the information about sensor and sensor readings
|
|
||||||
//Remarks: Configure the pin of arduino as input.
|
|
||||||
/************************************************************************************/
|
|
||||||
MQ131.serialDebug(true);
|
MQ131.serialDebug(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +43,14 @@ 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
|
||||||
|
|
||||||
|
/***************************** MQ Init ********************************************/
|
||||||
|
//Remarks: Configure the pin of arduino as input.
|
||||||
|
/************************************************************************************/
|
||||||
|
MQ135.init();
|
||||||
|
/*
|
||||||
|
//If the RL value is different from 10K please assign your RL value with the following method:
|
||||||
|
MQ135.setRL(10);
|
||||||
|
*/
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** 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 supposing before was pre-heated
|
||||||
@ -65,19 +72,6 @@ void setup() {
|
|||||||
if(isinf(calcR0)) {Serial.println("Warning: Conection issue founded, R0 is infite (Open circuit detected) please check your wiring and supply"); while(1);}
|
if(isinf(calcR0)) {Serial.println("Warning: Conection issue founded, R0 is infite (Open circuit detected) please check your wiring and supply"); while(1);}
|
||||||
if(calcR0 == 0){Serial.println("Warning: Conection issue founded, R0 is zero (Analog pin with short circuit to ground) please check your wiring and supply"); while(1);}
|
if(calcR0 == 0){Serial.println("Warning: Conection issue founded, R0 is zero (Analog pin with short circuit to ground) please check your wiring and supply"); while(1);}
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
|
|
||||||
/*
|
|
||||||
//If the RL value is different from 10K please assign your RL value with the following method:
|
|
||||||
MQ135.setRL(10);
|
|
||||||
*/
|
|
||||||
|
|
||||||
MQ135.init();
|
|
||||||
/***************************** MQ Init ********************************************/
|
|
||||||
//Input: setup flag, if this function are on setup will print the headers (Optional - Default value: False)
|
|
||||||
//Output: print on serial port the information about sensor and sensor readings
|
|
||||||
//Remarks: Configure the pin of arduino as input.
|
|
||||||
/************************************************************************************/
|
|
||||||
|
|
||||||
Serial.println("** Lectures from MQ-135 ****");
|
Serial.println("** Lectures from MQ-135 ****");
|
||||||
Serial.println("| CO | Alcohol | CO2 | Tolueno | NH4 | Acteona |");
|
Serial.println("| CO | Alcohol | CO2 | Tolueno | NH4 | Acteona |");
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,14 @@ void setup() {
|
|||||||
Acetona | 34.668 | -3.369
|
Acetona | 34.668 | -3.369
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/***************************** MQ Init ********************************************/
|
||||||
|
//Remarks: Configure the pin of arduino as input.
|
||||||
|
/************************************************************************************/
|
||||||
|
MQ135.init();
|
||||||
|
/*
|
||||||
|
//If the RL value is different from 10K please assign your RL value with the following method:
|
||||||
|
MQ135.setRL(10);
|
||||||
|
*/
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** 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 supposing before was pre-heated
|
||||||
@ -77,21 +84,6 @@ void setup() {
|
|||||||
if(isinf(calcR0)) {Serial.println("Warning: Conection issue founded, R0 is infite (Open circuit detected) please check your wiring and supply"); while(1);}
|
if(isinf(calcR0)) {Serial.println("Warning: Conection issue founded, R0 is infite (Open circuit detected) please check your wiring and supply"); while(1);}
|
||||||
if(calcR0 == 0){Serial.println("Warning: Conection issue founded, R0 is zero (Analog pin with short circuit to ground) please check your wiring and supply"); while(1);}
|
if(calcR0 == 0){Serial.println("Warning: Conection issue founded, R0 is zero (Analog pin with short circuit to ground) please check your wiring and supply"); while(1);}
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
|
|
||||||
/*
|
|
||||||
//If the RL value is different from 10K please assign your RL value with the following method:
|
|
||||||
MQ135.setRL(10);
|
|
||||||
*/
|
|
||||||
|
|
||||||
/***************************** MQ Init ********************************************/
|
|
||||||
//Remarks: Configure the pin of arduino as input.
|
|
||||||
/************************************************************************************/
|
|
||||||
MQ135.init();
|
|
||||||
/***************************** MQ Init ********************************************/
|
|
||||||
//Input: setup flag, if this function are on setup will print the headers (Optional - Default value: False)
|
|
||||||
//Output: print on serial port the information about sensor and sensor readings
|
|
||||||
//Remarks: Configure the pin of arduino as input.
|
|
||||||
/************************************************************************************/
|
|
||||||
MQ135.serialDebug(true);
|
MQ135.serialDebug(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,17 +22,18 @@
|
|||||||
|
|
||||||
//Include the library
|
//Include the library
|
||||||
#include <MQUnifiedsensor.h>
|
#include <MQUnifiedsensor.h>
|
||||||
|
/************************Hardware Related Macros************************************/
|
||||||
|
#define Board ("Arduino UNO")
|
||||||
|
#define Pin (A2) //Analog input 3 of your arduino
|
||||||
|
/***********************Software Related Macros************************************/
|
||||||
|
#define Type ("MQ-2") //MQ2
|
||||||
|
#define Voltage_Resolution (5)
|
||||||
|
#define ADC_Bit_Resolution (10) // For arduino UNO/MEGA/NANO
|
||||||
|
#define RatioMQ2CleanAir (9.83) //RS / R0 = 9.83 ppm
|
||||||
|
|
||||||
//Definitions
|
/*****************************Globals***********************************************/
|
||||||
#define placa "Arduino UNO"
|
MQUnifiedsensor MQ2(Board, Voltage_Resolution, ADC_Bit_Resolution, Pin, Type);
|
||||||
#define Voltage_Resolution 5
|
/*****************************Globals***********************************************/
|
||||||
#define pin A0 //Analog input 0 of your arduino
|
|
||||||
#define type "MQ-2" //MQ2
|
|
||||||
#define ADC_Bit_Resolution 10 // For arduino UNO/MEGA/NANO
|
|
||||||
#define RatioMQ2CleanAir 9.83 //RS / R0 = 9.83 ppm
|
|
||||||
|
|
||||||
//Declare Sensor
|
|
||||||
MQUnifiedsensor MQ2(placa, Voltage_Resolution, ADC_Bit_Resolution, pin, type);
|
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
//Init the serial port communication - to debug the library
|
//Init the serial port communication - to debug the library
|
||||||
@ -51,6 +52,14 @@ void setup() {
|
|||||||
Propane| 658.71 | -2.168
|
Propane| 658.71 | -2.168
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/***************************** MQ Init ********************************************/
|
||||||
|
//Remarks: Configure the pin of arduino as input.
|
||||||
|
/************************************************************************************/
|
||||||
|
MQ2.init();
|
||||||
|
/*
|
||||||
|
//If the RL value is different from 10K please assign your RL value with the following method:
|
||||||
|
MQ2.setRL(10);
|
||||||
|
*/
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** 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 supposing before was pre-heated
|
||||||
@ -72,20 +81,7 @@ void setup() {
|
|||||||
if(isinf(calcR0)) {Serial.println("Warning: Conection issue founded, R0 is infite (Open circuit detected) please check your wiring and supply"); while(1);}
|
if(isinf(calcR0)) {Serial.println("Warning: Conection issue founded, R0 is infite (Open circuit detected) please check your wiring and supply"); while(1);}
|
||||||
if(calcR0 == 0){Serial.println("Warning: Conection issue founded, R0 is zero (Analog pin with short circuit to ground) please check your wiring and supply"); while(1);}
|
if(calcR0 == 0){Serial.println("Warning: Conection issue founded, R0 is zero (Analog pin with short circuit to ground) please check your wiring and supply"); while(1);}
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
/*
|
|
||||||
//If the RL value is different from 10K please assign your RL value with the following method:
|
|
||||||
MQ2.setRL(10);
|
|
||||||
*/
|
|
||||||
|
|
||||||
/***************************** MQ Init ********************************************/
|
|
||||||
//Remarks: Configure the pin of arduino as input.
|
|
||||||
/************************************************************************************/
|
|
||||||
MQ2.init();
|
|
||||||
/***************************** MQ Init ********************************************/
|
|
||||||
//Input: setup flag, if this function are on setup will print the headers (Optional - Default value: False)
|
|
||||||
//Output: print on serial port the information about sensor and sensor readings
|
|
||||||
//Remarks: Configure the pin of arduino as input.
|
|
||||||
/************************************************************************************/
|
|
||||||
MQ2.serialDebug(true);
|
MQ2.serialDebug(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,18 +23,17 @@
|
|||||||
|
|
||||||
//Include the library
|
//Include the library
|
||||||
#include <MQUnifiedsensor.h>
|
#include <MQUnifiedsensor.h>
|
||||||
|
/************************Hardware Related Macros************************************/
|
||||||
//Definitions
|
#define Board ("Arduino UNO")
|
||||||
#define placa "Arduino UNO"
|
#define Pin (A3) //Analog input 3 of your arduino
|
||||||
#define Voltage_Resolution 5
|
/***********************Software Related Macros************************************/
|
||||||
#define pin A0 //Analog input 0 of your arduino
|
#define Type ("MQ-3") //MQ3
|
||||||
#define type "MQ-3" //MQ3
|
#define Voltage_Resolution (5)
|
||||||
#define ADC_Bit_Resolution 10 // For arduino UNO/MEGA/NANO
|
#define ADC_Bit_Resolution (10) // For arduino UNO/MEGA/NANO
|
||||||
#define RatioMQ3CleanAir 60 //RS / R0 = 60 ppm
|
#define RatioMQ3CleanAir (60) //RS / R0 = 60 ppm
|
||||||
//#define calibration_button 13 //Pin to calibrate your sensor
|
/*****************************Globals***********************************************/
|
||||||
|
|
||||||
//Declare Sensor
|
//Declare Sensor
|
||||||
MQUnifiedsensor MQ3(placa, Voltage_Resolution, ADC_Bit_Resolution, pin, type);
|
MQUnifiedsensor MQ3(Board, Voltage_Resolution, ADC_Bit_Resolution, Pin, Type);
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
//Init the serial port communication - to debug the library
|
//Init the serial port communication - to debug the library
|
||||||
@ -54,7 +53,15 @@ void setup() {
|
|||||||
Hexane | 7585.3 | -2.849
|
Hexane | 7585.3 | -2.849
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/***************************** MQ Init ********************************************/
|
||||||
|
//Remarks: Configure the pin of arduino as input.
|
||||||
|
/************************************************************************************/
|
||||||
|
MQ3.init();
|
||||||
|
|
||||||
|
/*
|
||||||
|
//If the RL value is different from 10K please assign your RL value with the following method:
|
||||||
|
MQ3.setRL(10);
|
||||||
|
*/
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** 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 supposing before was pre-heated
|
||||||
@ -76,21 +83,6 @@ void setup() {
|
|||||||
if(isinf(calcR0)) {Serial.println("Warning: Conection issue founded, R0 is infite (Open circuit detected) please check your wiring and supply"); while(1);}
|
if(isinf(calcR0)) {Serial.println("Warning: Conection issue founded, R0 is infite (Open circuit detected) please check your wiring and supply"); while(1);}
|
||||||
if(calcR0 == 0){Serial.println("Warning: Conection issue founded, R0 is zero (Analog pin with short circuit to ground) please check your wiring and supply"); while(1);}
|
if(calcR0 == 0){Serial.println("Warning: Conection issue founded, R0 is zero (Analog pin with short circuit to ground) please check your wiring and supply"); while(1);}
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
|
|
||||||
/*
|
|
||||||
//If the RL value is different from 10K please assign your RL value with the following method:
|
|
||||||
MQ3.setRL(10);
|
|
||||||
*/
|
|
||||||
|
|
||||||
/***************************** MQ Init ********************************************/
|
|
||||||
//Remarks: Configure the pin of arduino as input.
|
|
||||||
/************************************************************************************/
|
|
||||||
MQ3.init();
|
|
||||||
/***************************** MQ Init ********************************************/
|
|
||||||
//Input: setup flag, if this function are on setup will print the headers (Optional - Default value: False)
|
|
||||||
//Output: print on serial port the information about sensor and sensor readings
|
|
||||||
//Remarks: Configure the pin of arduino as input.
|
|
||||||
/************************************************************************************/
|
|
||||||
MQ3.serialDebug(true);
|
MQ3.serialDebug(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +52,14 @@ void setup() {
|
|||||||
Ethanol | 3.4916 | -2.432
|
Ethanol | 3.4916 | -2.432
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/***************************** MQ Init ********************************************/
|
||||||
|
//Remarks: Configure the pin of arduino as input.
|
||||||
|
/************************************************************************************/
|
||||||
|
MQ303.init();
|
||||||
|
/*
|
||||||
|
//If the RL value is different from 10K please assign your RL value with the following method:
|
||||||
|
MQ303.setRL(10);
|
||||||
|
*/
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** 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 supposing before was pre-heated
|
||||||
@ -74,21 +81,6 @@ void setup() {
|
|||||||
if(isinf(calcR0)) {Serial.println("Warning: Conection issue founded, R0 is infite (Open circuit detected) please check your wiring and supply"); while(1);}
|
if(isinf(calcR0)) {Serial.println("Warning: Conection issue founded, R0 is infite (Open circuit detected) please check your wiring and supply"); while(1);}
|
||||||
if(calcR0 == 0){Serial.println("Warning: Conection issue founded, R0 is zero (Analog pin with short circuit to ground) please check your wiring and supply"); while(1);}
|
if(calcR0 == 0){Serial.println("Warning: Conection issue founded, R0 is zero (Analog pin with short circuit to ground) please check your wiring and supply"); while(1);}
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
|
|
||||||
/*
|
|
||||||
//If the RL value is different from 10K please assign your RL value with the following method:
|
|
||||||
MQ303.setRL(10);
|
|
||||||
*/
|
|
||||||
|
|
||||||
/***************************** MQ Init ********************************************/
|
|
||||||
//Remarks: Configure the pin of arduino as input.
|
|
||||||
/************************************************************************************/
|
|
||||||
MQ303.init();
|
|
||||||
/***************************** MQ Init ********************************************/
|
|
||||||
//Input: setup flag, if this function are on setup will print the headers (Optional - Default value: False)
|
|
||||||
//Output: print on serial port the information about sensor and sensor readings
|
|
||||||
//Remarks: Configure the pin of arduino as input.
|
|
||||||
/************************************************************************************/
|
|
||||||
MQ303.serialDebug(true);
|
MQ303.serialDebug(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,7 +53,14 @@ void setup() {
|
|||||||
ALCOHOL | 473622 | -3.647
|
ALCOHOL | 473622 | -3.647
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/***************************** MQ Init ********************************************/
|
||||||
|
//Remarks: Configure the pin of arduino as input.
|
||||||
|
/************************************************************************************/
|
||||||
|
MQ309.init();
|
||||||
|
/*
|
||||||
|
//If the RL value is different from 10K please assign your RL value with the following method:
|
||||||
|
MQ309.setRL(10);
|
||||||
|
*/
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** 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 supposing before was pre-heated
|
||||||
@ -75,21 +82,6 @@ void setup() {
|
|||||||
if(isinf(calcR0)) {Serial.println("Warning: Conection issue founded, R0 is infite (Open circuit detected) please check your wiring and supply"); while(1);}
|
if(isinf(calcR0)) {Serial.println("Warning: Conection issue founded, R0 is infite (Open circuit detected) please check your wiring and supply"); while(1);}
|
||||||
if(calcR0 == 0){Serial.println("Warning: Conection issue founded, R0 is zero (Analog pin with short circuit to ground) please check your wiring and supply"); while(1);}
|
if(calcR0 == 0){Serial.println("Warning: Conection issue founded, R0 is zero (Analog pin with short circuit to ground) please check your wiring and supply"); while(1);}
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
|
|
||||||
/*
|
|
||||||
//If the RL value is different from 10K please assign your RL value with the following method:
|
|
||||||
MQ309.setRL(10);
|
|
||||||
*/
|
|
||||||
|
|
||||||
/***************************** MQ Init ********************************************/
|
|
||||||
//Remarks: Configure the pin of arduino as input.
|
|
||||||
/************************************************************************************/
|
|
||||||
MQ309.init();
|
|
||||||
/***************************** MQ Init ********************************************/
|
|
||||||
//Input: setup flag, if this function are on setup will print the headers (Optional - Default value: False)
|
|
||||||
//Output: print on serial port the information about sensor and sensor readings
|
|
||||||
//Remarks: Configure the pin of arduino as input.
|
|
||||||
/************************************************************************************/
|
|
||||||
MQ309.serialDebug(true);
|
MQ309.serialDebug(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,18 +23,17 @@
|
|||||||
|
|
||||||
//Include the library
|
//Include the library
|
||||||
#include <MQUnifiedsensor.h>
|
#include <MQUnifiedsensor.h>
|
||||||
|
/************************Hardware Related Macros************************************/
|
||||||
//Definitions
|
#define Board ("Arduino UNO")
|
||||||
#define placa "Arduino UNO"
|
#define Pin (A4) //Analog input 4 of your arduino
|
||||||
#define Voltage_Resolution 5
|
/***********************Software Related Macros************************************/
|
||||||
#define pin A0 //Analog input 0 of your arduino
|
#define Type ("MQ-4") //MQ4
|
||||||
#define type "MQ-4" //MQ4
|
#define Voltage_Resolution (5)
|
||||||
#define ADC_Bit_Resolution 10 // For arduino UNO/MEGA/NANO
|
#define ADC_Bit_Resolution (10) // For arduino UNO/MEGA/NANO
|
||||||
#define RatioMQ4CleanAir 4.4 //RS / R0 = 4.4 ppm
|
#define RatioMQ4CleanAir (4.4) //RS / R0 = 60 ppm
|
||||||
//#define calibration_button 13 //Pin to calibrate your sensor
|
/*****************************Globals***********************************************/
|
||||||
|
|
||||||
//Declare Sensor
|
//Declare Sensor
|
||||||
MQUnifiedsensor MQ4(placa, Voltage_Resolution, ADC_Bit_Resolution, pin, type);
|
MQUnifiedsensor MQ4(Board, Voltage_Resolution, ADC_Bit_Resolution, Pin, Type);
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
//Init the serial port communication - to debug the library
|
//Init the serial port communication - to debug the library
|
||||||
@ -44,7 +43,14 @@ void setup() {
|
|||||||
MQ4.setRegressionMethod(1); //_PPM = a*ratio^b
|
MQ4.setRegressionMethod(1); //_PPM = a*ratio^b
|
||||||
|
|
||||||
|
|
||||||
|
/***************************** MQ Init ********************************************/
|
||||||
|
//Remarks: Configure the pin of arduino as input.
|
||||||
|
/************************************************************************************/
|
||||||
|
MQ4.init();
|
||||||
|
/*
|
||||||
|
//If the RL value is different from 10K please assign your RL value with the following method:
|
||||||
|
MQ4.setRL(10);
|
||||||
|
*/
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** 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 supposing before was pre-heated
|
||||||
@ -67,18 +73,6 @@ void setup() {
|
|||||||
if(calcR0 == 0){Serial.println("Warning: Conection issue founded, R0 is zero (Analog pin with short circuit to ground) please check your wiring and supply"); while(1);}
|
if(calcR0 == 0){Serial.println("Warning: Conection issue founded, R0 is zero (Analog pin with short circuit to ground) please check your wiring and supply"); while(1);}
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
|
|
||||||
/*
|
|
||||||
//If the RL value is different from 10K please assign your RL value with the following method:
|
|
||||||
MQ4.setRL(10);
|
|
||||||
*/
|
|
||||||
|
|
||||||
/***************************** MQ Init ********************************************/
|
|
||||||
//Input: setup flag, if this function are on setup will print the headers (Optional - Default value: False)
|
|
||||||
//Output: print on serial port the information about sensor and sensor readings
|
|
||||||
//Remarks: Configure the pin of arduino as input.
|
|
||||||
/************************************************************************************/
|
|
||||||
MQ4.init();
|
|
||||||
|
|
||||||
Serial.println("*************** Lectures from MQ-4 **********************");
|
Serial.println("*************** Lectures from MQ-4 **********************");
|
||||||
Serial.println("| LPG | CH4 | CO | Alcohol | Smoke |");
|
Serial.println("| LPG | CH4 | CO | Alcohol | Smoke |");
|
||||||
}
|
}
|
||||||
|
@ -23,18 +23,17 @@
|
|||||||
|
|
||||||
//Include the library
|
//Include the library
|
||||||
#include <MQUnifiedsensor.h>
|
#include <MQUnifiedsensor.h>
|
||||||
|
/************************Hardware Related Macros************************************/
|
||||||
//Definitions
|
#define Board ("Arduino UNO")
|
||||||
#define placa "Arduino UNO"
|
#define Pin (A4) //Analog input 4 of your arduino
|
||||||
#define Voltage_Resolution 5
|
/***********************Software Related Macros************************************/
|
||||||
#define pin A4 //Analog input 4 of your arduino
|
#define Type ("MQ-4") //MQ4
|
||||||
#define type "MQ-4" //MQ4
|
#define Voltage_Resolution (5)
|
||||||
#define ADC_Bit_Resolution 10 // For arduino UNO/MEGA/NANO
|
#define ADC_Bit_Resolution (10) // For arduino UNO/MEGA/NANO
|
||||||
#define RatioMQ4CleanAir 4.4 //RS / R0 = 4.4 ppm
|
#define RatioMQ4CleanAir (4.4) //RS / R0 = 60 ppm
|
||||||
//#define calibration_button 13 //Pin to calibrate your sensor
|
/*****************************Globals***********************************************/
|
||||||
|
|
||||||
//Declare Sensor
|
//Declare Sensor
|
||||||
MQUnifiedsensor MQ4(placa, Voltage_Resolution, ADC_Bit_Resolution, pin, type);
|
MQUnifiedsensor MQ4(Board, Voltage_Resolution, ADC_Bit_Resolution, Pin, Type);
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
//Init the serial port communication - to debug the library
|
//Init the serial port communication - to debug the library
|
||||||
@ -43,8 +42,14 @@ 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(0); //_PPM = pow(10, (log10(ratio)-b)/a)
|
MQ4.setRegressionMethod(0); //_PPM = pow(10, (log10(ratio)-b)/a)
|
||||||
|
|
||||||
|
/***************************** MQ Init ********************************************/
|
||||||
|
//Remarks: Configure the pin of arduino as input.
|
||||||
|
/************************************************************************************/
|
||||||
|
MQ4.init();
|
||||||
|
/*
|
||||||
|
//If the RL value is different from 10K please assign your RL value with the following method:
|
||||||
|
MQ4.setRL(10);
|
||||||
|
*/
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** 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 supposing before was pre-heated
|
||||||
@ -67,18 +72,6 @@ void setup() {
|
|||||||
if(calcR0 == 0){Serial.println("Warning: Conection issue founded, R0 is zero (Analog pin with short circuit to ground) please check your wiring and supply"); while(1);}
|
if(calcR0 == 0){Serial.println("Warning: Conection issue founded, R0 is zero (Analog pin with short circuit to ground) please check your wiring and supply"); while(1);}
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
|
|
||||||
/*
|
|
||||||
//If the RL value is different from 10K please assign your RL value with the following method:
|
|
||||||
MQ4.setRL(10);
|
|
||||||
*/
|
|
||||||
|
|
||||||
/***************************** MQ Init ********************************************/
|
|
||||||
//Input: setup flag, if this function are on setup will print the headers (Optional - Default value: False)
|
|
||||||
//Output: print on serial port the information about sensor and sensor readings
|
|
||||||
//Remarks: Configure the pin of arduino as input.
|
|
||||||
/************************************************************************************/
|
|
||||||
MQ4.init();
|
|
||||||
|
|
||||||
Serial.println("** Lectures from MQ-4**********");
|
Serial.println("** Lectures from MQ-4**********");
|
||||||
Serial.println("| LPG |");
|
Serial.println("| LPG |");
|
||||||
}
|
}
|
||||||
|
@ -23,18 +23,17 @@
|
|||||||
|
|
||||||
//Include the library
|
//Include the library
|
||||||
#include <MQUnifiedsensor.h>
|
#include <MQUnifiedsensor.h>
|
||||||
|
/************************Hardware Related Macros************************************/
|
||||||
//Definitions
|
#define Board ("Arduino UNO")
|
||||||
#define placa "Arduino UNO"
|
#define Pin (A4) //Analog input 4 of your arduino
|
||||||
#define Voltage_Resolution 5
|
/***********************Software Related Macros************************************/
|
||||||
#define pin A0 //Analog input 0 of your arduino
|
#define Type ("MQ-4") //MQ4
|
||||||
#define type "MQ-4" //MQ4
|
#define Voltage_Resolution (5)
|
||||||
#define ADC_Bit_Resolution 10 // For arduino UNO/MEGA/NANO
|
#define ADC_Bit_Resolution (10) // For arduino UNO/MEGA/NANO
|
||||||
#define RatioMQ4CleanAir 4.4 //RS / R0 = 4.4 ppm
|
#define RatioMQ4CleanAir (4.4) //RS / R0 = 60 ppm
|
||||||
//#define calibration_button 13 //Pin to calibrate your sensor
|
/*****************************Globals***********************************************/
|
||||||
|
|
||||||
//Declare Sensor
|
//Declare Sensor
|
||||||
MQUnifiedsensor MQ4(placa, Voltage_Resolution, ADC_Bit_Resolution, pin, type);
|
MQUnifiedsensor MQ4(Board, Voltage_Resolution, ADC_Bit_Resolution, Pin, Type);
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
//Init the serial port communication - to debug the library
|
//Init the serial port communication - to debug the library
|
||||||
@ -54,7 +53,14 @@ void setup() {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/***************************** MQ Init ********************************************/
|
||||||
|
//Remarks: Configure the pin of arduino as input.
|
||||||
|
/************************************************************************************/
|
||||||
|
MQ4.init();
|
||||||
|
/*
|
||||||
|
//If the RL value is different from 10K please assign your RL value with the following method:
|
||||||
|
MQ4.setRL(10);
|
||||||
|
*/
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** 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 supposing before was pre-heated
|
||||||
@ -76,21 +82,6 @@ void setup() {
|
|||||||
if(isinf(calcR0)) {Serial.println("Warning: Conection issue founded, R0 is infite (Open circuit detected) please check your wiring and supply"); while(1);}
|
if(isinf(calcR0)) {Serial.println("Warning: Conection issue founded, R0 is infite (Open circuit detected) please check your wiring and supply"); while(1);}
|
||||||
if(calcR0 == 0){Serial.println("Warning: Conection issue founded, R0 is zero (Analog pin with short circuit to ground) please check your wiring and supply"); while(1);}
|
if(calcR0 == 0){Serial.println("Warning: Conection issue founded, R0 is zero (Analog pin with short circuit to ground) please check your wiring and supply"); while(1);}
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
|
|
||||||
/*
|
|
||||||
//If the RL value is different from 10K please assign your RL value with the following method:
|
|
||||||
MQ4.setRL(10);
|
|
||||||
*/
|
|
||||||
|
|
||||||
/***************************** MQ Init ********************************************/
|
|
||||||
//Remarks: Configure the pin of arduino as input.
|
|
||||||
/************************************************************************************/
|
|
||||||
MQ4.init();
|
|
||||||
/***************************** MQ Init ********************************************/
|
|
||||||
//Input: setup flag, if this function are on setup will print the headers (Optional - Default value: False)
|
|
||||||
//Output: print on serial port the information about sensor and sensor readings
|
|
||||||
//Remarks: Configure the pin of arduino as input.
|
|
||||||
/************************************************************************************/
|
|
||||||
MQ4.serialDebug(true);
|
MQ4.serialDebug(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,7 +53,14 @@ void setup() {
|
|||||||
Alcohol| 97124 | -4.918
|
Alcohol| 97124 | -4.918
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/***************************** MQ Init ********************************************/
|
||||||
|
//Remarks: Configure the pin of arduino as input.
|
||||||
|
/************************************************************************************/
|
||||||
|
MQ5.init();
|
||||||
|
/*
|
||||||
|
//If the RL value is different from 10K please assign your RL value with the following method:
|
||||||
|
MQ5.setRL(10);
|
||||||
|
*/
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** 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 supposing before was pre-heated
|
||||||
@ -75,21 +82,6 @@ void setup() {
|
|||||||
if(isinf(calcR0)) {Serial.println("Warning: Conection issue founded, R0 is infite (Open circuit detected) please check your wiring and supply"); while(1);}
|
if(isinf(calcR0)) {Serial.println("Warning: Conection issue founded, R0 is infite (Open circuit detected) please check your wiring and supply"); while(1);}
|
||||||
if(calcR0 == 0){Serial.println("Warning: Conection issue founded, R0 is zero (Analog pin with short circuit to ground) please check your wiring and supply"); while(1);}
|
if(calcR0 == 0){Serial.println("Warning: Conection issue founded, R0 is zero (Analog pin with short circuit to ground) please check your wiring and supply"); while(1);}
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
|
|
||||||
/*
|
|
||||||
//If the RL value is different from 10K please assign your RL value with the following method:
|
|
||||||
MQ5.setRL(10);
|
|
||||||
*/
|
|
||||||
|
|
||||||
/***************************** MQ Init ********************************************/
|
|
||||||
//Remarks: Configure the pin of arduino as input.
|
|
||||||
/************************************************************************************/
|
|
||||||
MQ5.init();
|
|
||||||
/***************************** MQ Init ********************************************/
|
|
||||||
//Input: setup flag, if this function are on setup will print the headers (Optional - Default value: False)
|
|
||||||
//Output: print on serial port the information about sensor and sensor readings
|
|
||||||
//Remarks: Configure the pin of arduino as input.
|
|
||||||
/************************************************************************************/
|
|
||||||
MQ5.serialDebug(true);
|
MQ5.serialDebug(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,7 +53,14 @@ void setup() {
|
|||||||
Alcohol | 50000000 | -6.017
|
Alcohol | 50000000 | -6.017
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/***************************** MQ Init ********************************************/
|
||||||
|
//Remarks: Configure the pin of arduino as input.
|
||||||
|
/************************************************************************************/
|
||||||
|
MQ6.init();
|
||||||
|
/*
|
||||||
|
//If the RL value is different from 10K please assign your RL value with the following method:
|
||||||
|
MQ6.setRL(10);
|
||||||
|
*/
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** 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 supposing before was pre-heated
|
||||||
@ -75,20 +82,6 @@ void setup() {
|
|||||||
if(isinf(calcR0)) {Serial.println("Warning: Conection issue founded, R0 is infite (Open circuit detected) please check your wiring and supply"); while(1);}
|
if(isinf(calcR0)) {Serial.println("Warning: Conection issue founded, R0 is infite (Open circuit detected) please check your wiring and supply"); while(1);}
|
||||||
if(calcR0 == 0){Serial.println("Warning: Conection issue founded, R0 is zero (Analog pin with short circuit to ground) please check your wiring and supply"); while(1);}
|
if(calcR0 == 0){Serial.println("Warning: Conection issue founded, R0 is zero (Analog pin with short circuit to ground) please check your wiring and supply"); while(1);}
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
/*
|
|
||||||
//If the RL value is different from 10K please assign your RL value with the following method:
|
|
||||||
MQ6.setRL(10);
|
|
||||||
*/
|
|
||||||
|
|
||||||
/***************************** MQ Init ********************************************/
|
|
||||||
//Remarks: Configure the pin of arduino as input.
|
|
||||||
/************************************************************************************/
|
|
||||||
MQ6.init();
|
|
||||||
/***************************** MQ Init ********************************************/
|
|
||||||
//Input: setup flag, if this function are on setup will print the headers (Optional - Default value: False)
|
|
||||||
//Output: print on serial port the information about sensor and sensor readings
|
|
||||||
//Remarks: Configure the pin of arduino as input.
|
|
||||||
/************************************************************************************/
|
|
||||||
MQ6.serialDebug(true);
|
MQ6.serialDebug(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,7 +54,14 @@ void setup() {
|
|||||||
Alcohol | 40000000000000000 | -12.35
|
Alcohol | 40000000000000000 | -12.35
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/***************************** MQ Init ********************************************/
|
||||||
|
//Remarks: Configure the pin of arduino as input.
|
||||||
|
/************************************************************************************/
|
||||||
|
MQ7.init();
|
||||||
|
/*
|
||||||
|
//If the RL value is different from 10K please assign your RL value with the following method:
|
||||||
|
MQ7.setRL(10);
|
||||||
|
*/
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** 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 supposing before was pre-heated
|
||||||
@ -76,21 +83,6 @@ void setup() {
|
|||||||
if(isinf(calcR0)) {Serial.println("Warning: Conection issue founded, R0 is infite (Open circuit detected) please check your wiring and supply"); while(1);}
|
if(isinf(calcR0)) {Serial.println("Warning: Conection issue founded, R0 is infite (Open circuit detected) please check your wiring and supply"); while(1);}
|
||||||
if(calcR0 == 0){Serial.println("Warning: Conection issue founded, R0 is zero (Analog pin with short circuit to ground) please check your wiring and supply"); while(1);}
|
if(calcR0 == 0){Serial.println("Warning: Conection issue founded, R0 is zero (Analog pin with short circuit to ground) please check your wiring and supply"); while(1);}
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
|
|
||||||
/*
|
|
||||||
//If the RL value is different from 10K please assign your RL value with the following method:
|
|
||||||
MQ7.setRL(10);
|
|
||||||
*/
|
|
||||||
|
|
||||||
/***************************** MQ Init ********************************************/
|
|
||||||
//Remarks: Configure the pin of arduino as input.
|
|
||||||
/************************************************************************************/
|
|
||||||
MQ7.init();
|
|
||||||
/***************************** MQ Init ********************************************/
|
|
||||||
//Input: setup flag, if this function are on setup will print the headers (Optional - Default value: False)
|
|
||||||
//Output: print on serial port the information about sensor and sensor readings
|
|
||||||
//Remarks: Configure the pin of arduino as input.
|
|
||||||
/************************************************************************************/
|
|
||||||
MQ7.serialDebug(true);
|
MQ7.serialDebug(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,7 +54,14 @@ void setup() {
|
|||||||
Alcohol | 76101 | -1.86
|
Alcohol | 76101 | -1.86
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/***************************** MQ Init ********************************************/
|
||||||
|
//Remarks: Configure the pin of arduino as input.
|
||||||
|
/************************************************************************************/
|
||||||
|
MQ8.init();
|
||||||
|
/*
|
||||||
|
//If the RL value is different from 10K please assign your RL value with the following method:
|
||||||
|
MQ8.setRL(10);
|
||||||
|
*/
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** 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 supposing before was pre-heated
|
||||||
@ -76,20 +83,6 @@ void setup() {
|
|||||||
if(isinf(calcR0)) {Serial.println("Warning: Conection issue founded, R0 is infite (Open circuit detected) please check your wiring and supply"); while(1);}
|
if(isinf(calcR0)) {Serial.println("Warning: Conection issue founded, R0 is infite (Open circuit detected) please check your wiring and supply"); while(1);}
|
||||||
if(calcR0 == 0){Serial.println("Warning: Conection issue founded, R0 is zero (Analog pin with short circuit to ground) please check your wiring and supply"); while(1);}
|
if(calcR0 == 0){Serial.println("Warning: Conection issue founded, R0 is zero (Analog pin with short circuit to ground) please check your wiring and supply"); while(1);}
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
/*
|
|
||||||
//If the RL value is different from 10K please assign your RL value with the following method:
|
|
||||||
MQ8.setRL(10);
|
|
||||||
*/
|
|
||||||
|
|
||||||
/***************************** MQ Init ********************************************/
|
|
||||||
//Remarks: Configure the pin of arduino as input.
|
|
||||||
/************************************************************************************/
|
|
||||||
MQ8.init();
|
|
||||||
/***************************** MQ Init ********************************************/
|
|
||||||
//Input: setup flag, if this function are on setup will print the headers (Optional - Default value: False)
|
|
||||||
//Output: print on serial port the information about sensor and sensor readings
|
|
||||||
//Remarks: Configure the pin of arduino as input.
|
|
||||||
/************************************************************************************/
|
|
||||||
MQ8.serialDebug(true);
|
MQ8.serialDebug(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,18 +23,17 @@
|
|||||||
|
|
||||||
//Include the library
|
//Include the library
|
||||||
#include <MQUnifiedsensor.h>
|
#include <MQUnifiedsensor.h>
|
||||||
|
/************************Hardware Related Macros************************************/
|
||||||
//Definitions
|
#define Board ("Arduino UNO")
|
||||||
#define placa "Arduino UNO"
|
#define Pin (A9) //Analog input 4 of your arduino
|
||||||
#define Voltage_Resolution 5
|
/***********************Software Related Macros************************************/
|
||||||
#define pin A0 //Analog input 0 of your arduino
|
#define Type ("MQ-9") //MQ9
|
||||||
#define type "MQ-9" //MQ9
|
#define Voltage_Resolution (5)
|
||||||
#define ADC_Bit_Resolution 10 // For arduino UNO/MEGA/NANO
|
#define ADC_Bit_Resolution (10) // For arduino UNO/MEGA/NANO
|
||||||
#define RatioMQ9CleanAir 9.6 //RS / R0 = 9.6 ppm
|
#define RatioMQ9CleanAir (9.6) //RS / R0 = 60 ppm
|
||||||
//#define calibration_button 13 //Pin to calibrate your sensor
|
/*****************************Globals***********************************************/
|
||||||
|
|
||||||
//Declare Sensor
|
//Declare Sensor
|
||||||
MQUnifiedsensor MQ9(placa, Voltage_Resolution, ADC_Bit_Resolution, pin, type);
|
MQUnifiedsensor MQ9(Board, Voltage_Resolution, ADC_Bit_Resolution, Pin, Type);
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
//Init the serial port communication - to debug the library
|
//Init the serial port communication - to debug the library
|
||||||
@ -44,6 +43,14 @@ void setup() {
|
|||||||
MQ9.setRegressionMethod(1); //_PPM = a*ratio^b
|
MQ9.setRegressionMethod(1); //_PPM = a*ratio^b
|
||||||
|
|
||||||
|
|
||||||
|
/***************************** MQ Init ********************************************/
|
||||||
|
//Remarks: Configure the pin of arduino as input.
|
||||||
|
/************************************************************************************/
|
||||||
|
MQ9.init();
|
||||||
|
/*
|
||||||
|
//If the RL value is different from 10K please assign your RL value with the following method:
|
||||||
|
MQ9.setRL(10);
|
||||||
|
*/
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** 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 supposing before was pre-heated
|
||||||
@ -65,19 +72,6 @@ void setup() {
|
|||||||
if(isinf(calcR0)) {Serial.println("Warning: Conection issue founded, R0 is infite (Open circuit detected) please check your wiring and supply"); while(1);}
|
if(isinf(calcR0)) {Serial.println("Warning: Conection issue founded, R0 is infite (Open circuit detected) please check your wiring and supply"); while(1);}
|
||||||
if(calcR0 == 0){Serial.println("Warning: Conection issue founded, R0 is zero (Analog pin with short circuit to ground) please check your wiring and supply"); while(1);}
|
if(calcR0 == 0){Serial.println("Warning: Conection issue founded, R0 is zero (Analog pin with short circuit to ground) please check your wiring and supply"); while(1);}
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
|
|
||||||
/*
|
|
||||||
//If the RL value is different from 10K please assign your RL value with the following method:
|
|
||||||
MQ9.setRL(10);
|
|
||||||
*/
|
|
||||||
|
|
||||||
/***************************** MQ Init ********************************************/
|
|
||||||
//Input: setup flag, if this function are on setup will print the headers (Optional - Default value: False)
|
|
||||||
//Output: print on serial port the information about sensor and sensor readings
|
|
||||||
//Remarks: Configure the pin of arduino as input.
|
|
||||||
/************************************************************************************/
|
|
||||||
MQ9.init();
|
|
||||||
|
|
||||||
Serial.println("** Lectures from MQ-9 ****");
|
Serial.println("** Lectures from MQ-9 ****");
|
||||||
Serial.println("| LPG | CH4 | CO |");
|
Serial.println("| LPG | CH4 | CO |");
|
||||||
}
|
}
|
||||||
|
@ -23,18 +23,17 @@
|
|||||||
|
|
||||||
//Include the library
|
//Include the library
|
||||||
#include <MQUnifiedsensor.h>
|
#include <MQUnifiedsensor.h>
|
||||||
|
/************************Hardware Related Macros************************************/
|
||||||
//Definitions
|
#define Board ("Arduino UNO")
|
||||||
#define placa "Arduino UNO"
|
#define Pin (A9) //Analog input 4 of your arduino
|
||||||
#define Voltage_Resolution 5
|
/***********************Software Related Macros************************************/
|
||||||
#define pin A0 //Analog input 0 of your arduino
|
#define Type ("MQ-9") //MQ9
|
||||||
#define type "MQ-9" //MQ9
|
#define Voltage_Resolution (5)
|
||||||
#define ADC_Bit_Resolution 10 // For arduino UNO/MEGA/NANO
|
#define ADC_Bit_Resolution (10) // For arduino UNO/MEGA/NANO
|
||||||
#define RatioMQ9CleanAir 9.6 //RS / R0 = 9.6 ppm
|
#define RatioMQ9CleanAir (9.6) //RS / R0 = 60 ppm
|
||||||
//#define calibration_button 13 //Pin to calibrate your sensor
|
/*****************************Globals***********************************************/
|
||||||
|
|
||||||
//Declare Sensor
|
//Declare Sensor
|
||||||
MQUnifiedsensor MQ9(placa, Voltage_Resolution, ADC_Bit_Resolution, pin, type);
|
MQUnifiedsensor MQ9(Board, Voltage_Resolution, ADC_Bit_Resolution, Pin, Type);
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
//Init the serial port communication - to debug the library
|
//Init the serial port communication - to debug the library
|
||||||
@ -52,7 +51,14 @@ void setup() {
|
|||||||
CO | 599.65 | -2.244
|
CO | 599.65 | -2.244
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/***************************** MQ Init ********************************************/
|
||||||
|
//Remarks: Configure the pin of arduino as input.
|
||||||
|
/************************************************************************************/
|
||||||
|
MQ9.init();
|
||||||
|
/*
|
||||||
|
//If the RL value is different from 10K please assign your RL value with the following method:
|
||||||
|
MQ9.setRL(10);
|
||||||
|
*/
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** 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 supposing before was pre-heated
|
||||||
@ -74,21 +80,6 @@ void setup() {
|
|||||||
if(isinf(calcR0)) {Serial.println("Warning: Conection issue founded, R0 is infite (Open circuit detected) please check your wiring and supply"); while(1);}
|
if(isinf(calcR0)) {Serial.println("Warning: Conection issue founded, R0 is infite (Open circuit detected) please check your wiring and supply"); while(1);}
|
||||||
if(calcR0 == 0){Serial.println("Warning: Conection issue founded, R0 is zero (Analog pin with short circuit to ground) please check your wiring and supply"); while(1);}
|
if(calcR0 == 0){Serial.println("Warning: Conection issue founded, R0 is zero (Analog pin with short circuit to ground) please check your wiring and supply"); while(1);}
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
|
|
||||||
/*
|
|
||||||
//If the RL value is different from 10K please assign your RL value with the following method:
|
|
||||||
MQ9.setRL(10);
|
|
||||||
*/
|
|
||||||
|
|
||||||
/***************************** MQ Init ********************************************/
|
|
||||||
//Remarks: Configure the pin of arduino as input.
|
|
||||||
/************************************************************************************/
|
|
||||||
MQ9.init();
|
|
||||||
/***************************** MQ Init ********************************************/
|
|
||||||
//Input: setup flag, if this function are on setup will print the headers (Optional - Default value: False)
|
|
||||||
//Output: print on serial port the information about sensor and sensor readings
|
|
||||||
//Remarks: Configure the pin of arduino as input.
|
|
||||||
/************************************************************************************/
|
|
||||||
MQ9.serialDebug(true);
|
MQ9.serialDebug(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,39 +19,38 @@
|
|||||||
|
|
||||||
//Include the library
|
//Include the library
|
||||||
#include <MQUnifiedsensor.h>
|
#include <MQUnifiedsensor.h>
|
||||||
|
/************************Hardware Related Macros************************************/
|
||||||
//Definitions
|
#define Board ("Arduino Mega")
|
||||||
#define placa "Arduino Mega 2560"
|
#define Pin2 (A2) //Analog input 2 of your arduino
|
||||||
#define Voltage_Resolution 5
|
#define Pin3 (A3) //Analog input 3 of your arduino
|
||||||
#define type "MQ-Board"
|
#define Pin4 (A4) //Analog input 4 of your arduino
|
||||||
#define ADC_Bit_Resolution 10 // For arduino UNO/MEGA/NANO
|
#define Pin5 (A5) //Analog input 5 of your arduino
|
||||||
#define pin2 A2 //Analog input 2 of your arduino
|
#define Pin6 (A6) //Analog input 6 of your arduino
|
||||||
#define pin3 A3 //Analog input 3 of your arduino
|
#define Pin7 (A7) //Analog input 7 of your arduino
|
||||||
#define pin4 A4 //Analog input 4 of your arduino
|
#define Pin8 (A8) //Analog input 8 of your arduino
|
||||||
#define pin5 A5 //Analog input 5 of your arduino
|
#define Pin9 (A9) //Analog input 9 of your arduino
|
||||||
#define pin6 A6 //Analog input 6 of your arduino
|
/***********************Software Related Macros************************************/
|
||||||
#define pin7 A7 //Analog input 7 of your arduino
|
#define RatioMQ2CleanAir (9.83) //RS / R0 = 9.83 ppm
|
||||||
#define pin8 A8 //Analog input 8 of your arduino
|
#define RatioMQ3CleanAir (60) //RS / R0 = 60 ppm
|
||||||
#define pin9 A9 //Analog input 9 of your arduino
|
#define RatioMQ4CleanAir (4.4) //RS / R0 = 4.4 ppm
|
||||||
|
#define RatioMQ5CleanAir (6.5) //RS / R0 = 6.5 ppm
|
||||||
#define RatioMQ2CleanAir 9.83 //RS / R0 = 9.83 ppm
|
#define RatioMQ6CleanAir (10) //RS / R0 = 10 ppm
|
||||||
#define RatioMQ3CleanAir 60 //RS / R0 = 60 ppm
|
#define RatioMQ7CleanAir (27.5) //RS / R0 = 27.5 ppm
|
||||||
#define RatioMQ4CleanAir 4.4 //RS / R0 = 4.4 ppm
|
#define RatioMQ8CleanAir (70) //RS / R0 = 70 ppm
|
||||||
#define RatioMQ5CleanAir 6.5 //RS / R0 = 6.5 ppm
|
#define RatioMQ9CleanAir (9.6) //RS / R0 = 9.6 ppm
|
||||||
#define RatioMQ6CleanAir 10 //RS / R0 = 10 ppm
|
#define ADC_Bit_Resolution (10) // 10 bit ADC
|
||||||
#define RatioMQ7CleanAir 27.5 //RS / R0 = 27.5 ppm
|
#define Voltage_Resolution (5) // Volt resolution to calc the voltage
|
||||||
#define RatioMQ8CleanAir 70 //RS / R0 = 70 ppm
|
#define Type ("Arduino Mega 2560") //Board used
|
||||||
#define RatioMQ9CleanAir 9.6 //RS / R0 = 9.6 ppm
|
/*****************************Globals***********************************************/
|
||||||
|
|
||||||
//Declare Sensor
|
//Declare Sensor
|
||||||
MQUnifiedsensor MQ2(placa, Voltage_Resolution, ADC_Bit_Resolution, pin2, type);
|
MQUnifiedsensor MQ2(Board, Voltage_Resolution, ADC_Bit_Resolution, Pin2, Type);
|
||||||
MQUnifiedsensor MQ3(placa, Voltage_Resolution, ADC_Bit_Resolution, pin3, type);
|
MQUnifiedsensor MQ3(Board, Voltage_Resolution, ADC_Bit_Resolution, Pin3, Type);
|
||||||
MQUnifiedsensor MQ4(placa, Voltage_Resolution, ADC_Bit_Resolution, pin4, type);
|
MQUnifiedsensor MQ4(Board, Voltage_Resolution, ADC_Bit_Resolution, Pin4, Type);
|
||||||
MQUnifiedsensor MQ5(placa, Voltage_Resolution, ADC_Bit_Resolution, pin5, type);
|
MQUnifiedsensor MQ5(Board, Voltage_Resolution, ADC_Bit_Resolution, Pin5, Type);
|
||||||
MQUnifiedsensor MQ6(placa, Voltage_Resolution, ADC_Bit_Resolution, pin6, type);
|
MQUnifiedsensor MQ6(Board, Voltage_Resolution, ADC_Bit_Resolution, Pin6, Type);
|
||||||
MQUnifiedsensor MQ7(placa, Voltage_Resolution, ADC_Bit_Resolution, pin7, type);
|
MQUnifiedsensor MQ7(Board, Voltage_Resolution, ADC_Bit_Resolution, Pin7, Type);
|
||||||
MQUnifiedsensor MQ8(placa, Voltage_Resolution, ADC_Bit_Resolution, pin8, type);
|
MQUnifiedsensor MQ8(Board, Voltage_Resolution, ADC_Bit_Resolution, Pin8, Type);
|
||||||
MQUnifiedsensor MQ9(placa, Voltage_Resolution, ADC_Bit_Resolution, pin9, type);
|
MQUnifiedsensor MQ9(Board, Voltage_Resolution, ADC_Bit_Resolution, Pin9, Type);
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
//Init serial port
|
//Init serial port
|
||||||
@ -178,28 +177,6 @@ void loop() {
|
|||||||
MQ7.update();
|
MQ7.update();
|
||||||
MQ8.update();
|
MQ8.update();
|
||||||
MQ9.update();
|
MQ9.update();
|
||||||
/*
|
|
||||||
//Rutina de calibracion - Uncomment if you need (setup too and header)
|
|
||||||
if(calibration_button)
|
|
||||||
{
|
|
||||||
float R0 = MQ2.calibrate();
|
|
||||||
MQ2.setR0(R0):
|
|
||||||
R0 = MQ3.calibrate();
|
|
||||||
MQ3.setR0(R0):
|
|
||||||
R0 = MQ4.calibrate();
|
|
||||||
MQ4.setR0(R0):
|
|
||||||
R0 = MQ5.calibrate();
|
|
||||||
MQ5.setR0(R0):
|
|
||||||
R0 = MQ6.calibrate();
|
|
||||||
MQ6.setR0(R0):
|
|
||||||
R0 = MQ7.calibrate();
|
|
||||||
MQ7.setR0(R0):
|
|
||||||
R0 = MQ8.calibrate();
|
|
||||||
MQ8.setR0(R0):
|
|
||||||
R0 = MQ9.calibrate();
|
|
||||||
MQ9.setR0(R0):
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
//Read the sensor and print in serial port
|
//Read the sensor and print in serial port
|
||||||
float MQ2Lecture = MQ2.readSensor();
|
float MQ2Lecture = MQ2.readSensor();
|
||||||
float MQ3Lecture = MQ3.readSensor();
|
float MQ3Lecture = MQ3.readSensor();
|
||||||
|
@ -18,6 +18,8 @@
|
|||||||
Please take care, arduino A0 pin represent the analog input configured on #define pin - For this example this doesn't matter
|
Please take care, arduino A0 pin represent the analog input configured on #define pin - For this example this doesn't matter
|
||||||
You will connect your sensor to your external A2D Sensor
|
You will connect your sensor to your external A2D Sensor
|
||||||
|
|
||||||
|
This example code is in the public domain.
|
||||||
|
|
||||||
Important:
|
Important:
|
||||||
1. Although it doesn't matter what pin you put in when initializing your MQ sensor function it is important that you don't
|
1. Although it doesn't matter what pin you put in when initializing your MQ sensor function it is important that you don't
|
||||||
for any reason invoke the MQ.init() method because that method configures the selected pin as input and you may need it for
|
for any reason invoke the MQ.init() method because that method configures the selected pin as input and you may need it for
|
||||||
@ -27,10 +29,6 @@
|
|||||||
3. You must ensure that when invoking the setADC(value) method the value you are passing is within the expected parameters,
|
3. You must ensure that when invoking the setADC(value) method the value you are passing is within the expected parameters,
|
||||||
for example if it is a 10-bit ADC converter, we expect a value between 0 and 2^10 = 1024
|
for example if it is a 10-bit ADC converter, we expect a value between 0 and 2^10 = 1024
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
This example code is in the public domain.
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//Include the library
|
//Include the library
|
||||||
@ -67,6 +65,11 @@ void setup() {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
//If the RL value is different from 10K please assign your RL value with the following method:
|
||||||
|
MQ3.setRL(10);
|
||||||
|
*/
|
||||||
|
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** 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 supposing before was pre-heated
|
||||||
@ -90,11 +93,6 @@ void setup() {
|
|||||||
if(calcR0 == 0){Serial.println("Warning: Conection issue founded, R0 is zero (Analog pin with short circuit to ground) please check your wiring and supply"); while(1);}
|
if(calcR0 == 0){Serial.println("Warning: Conection issue founded, R0 is zero (Analog pin with short circuit to ground) please check your wiring and supply"); while(1);}
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
|
|
||||||
/*
|
|
||||||
//If the RL value is different from 10K please assign your RL value with the following method:
|
|
||||||
MQ3.setRL(10);
|
|
||||||
*/
|
|
||||||
|
|
||||||
MQ3.serialDebug(true);
|
MQ3.serialDebug(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,7 +51,10 @@ void setup() {
|
|||||||
//Remarks: Configure the pin of arduino as input.
|
//Remarks: Configure the pin of arduino as input.
|
||||||
/************************************************************************************/
|
/************************************************************************************/
|
||||||
MQ4.init();
|
MQ4.init();
|
||||||
|
/*
|
||||||
|
//If the RL value is different from 10K please assign your RL value with the following method:
|
||||||
|
MQ4.setRL(10);
|
||||||
|
*/
|
||||||
/***************************** 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 supposing before was pre-heated
|
||||||
@ -73,12 +76,6 @@ void setup() {
|
|||||||
if(isinf(calcR0)) {Serial.println("Warning: Conection issue founded, R0 is infite (Open circuit detected) please check your wiring and supply"); while(1);}
|
if(isinf(calcR0)) {Serial.println("Warning: Conection issue founded, R0 is infite (Open circuit detected) please check your wiring and supply"); while(1);}
|
||||||
if(calcR0 == 0){Serial.println("Warning: Conection issue founded, R0 is zero (Analog pin with short circuit to ground) please check your wiring and supply"); while(1);}
|
if(calcR0 == 0){Serial.println("Warning: Conection issue founded, R0 is zero (Analog pin with short circuit to ground) please check your wiring and supply"); while(1);}
|
||||||
/***************************** MQ CAlibration ********************************************/
|
/***************************** MQ CAlibration ********************************************/
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
//If the RL value is different from 10K please assign your RL value with the following method:
|
|
||||||
MQ4.setRL(10);
|
|
||||||
*/
|
|
||||||
MQ4.serialDebug(true);
|
MQ4.serialDebug(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
name=MQUnifiedsensor
|
name=MQUnifiedsensor
|
||||||
version=1.9.9.2
|
version=2.0
|
||||||
author= Miguel Califa <miguelangel5612@gmail.com>, Yersson Carrillo, Ghiordy Contreras
|
author= Miguel Califa <miguelangel5612@gmail.com>, Yersson Carrillo<miguelangel5612@gmail.com>, Ghiordy Contreras<miguelangel5612@gmail.com>
|
||||||
maintainer= Miguel Califa <miguelangel5612@gmail.com>
|
maintainer= Miguel Califa <miguelangel5612@gmail.com>
|
||||||
sentence= This library allows you to read the MQ sensors very easily.
|
sentence= This library allows you to read the MQ sensors very easily.
|
||||||
paragraph= This library allows an Arduino/Genuino/ESP8266 board to read MQ Sensors (AIr quality meter) references: MQ2, MQ3, MQ4, MQ5, MQ6, MQ7, MQ8, MQ9, MQ131, MQ135, MQ303A, MQ309A.
|
paragraph= This library allows an Arduino/Genuino/ESP8266 board to read MQ Sensors (AIr quality meter) references: MQ2, MQ3, MQ4, MQ5, MQ6, MQ7, MQ8, MQ9, MQ131, MQ135, MQ303A, MQ309A.
|
||||||
|
@ -80,7 +80,7 @@ void MQUnifiedsensor::serialDebug(bool onSetup)
|
|||||||
Serial.print("R0: "); Serial.print(_R0); Serial.println(" KΩ");
|
Serial.print("R0: "); Serial.print(_R0); Serial.println(" KΩ");
|
||||||
Serial.print("RL: "); Serial.print(_RL); Serial.println(" KΩ");
|
Serial.print("RL: "); Serial.print(_RL); Serial.println(" KΩ");
|
||||||
|
|
||||||
Serial.print("Model: "); if(_regressionMethod == "Exponential") Serial.println("Exponential"); else Serial.println("Linear");
|
Serial.print("Model: "); if(_regressionMethod == 1) Serial.println("Exponential"); else Serial.println("Linear");
|
||||||
Serial.print(_type); Serial.print(" -> a: "); Serial.print(_a); Serial.print(" | b: "); Serial.println(_b);
|
Serial.print(_type); Serial.print(" -> a: "); Serial.print(_a); Serial.print(" | b: "); Serial.println(_b);
|
||||||
|
|
||||||
Serial.print("Development board: "); Serial.println(_placa);
|
Serial.print("Development board: "); Serial.println(_placa);
|
||||||
|
Reference in New Issue
Block a user