mirror of
https://github.com/miguel5612/MQSensorsLib.git
synced 2025-03-15 05:17:30 +03:00
Updated basic examples
This commit is contained in:
parent
d0f49fa4f0
commit
9a1974033e
@ -26,6 +26,7 @@
|
||||
#define pin A0 //Analog input 0 of your arduino
|
||||
#define type "MQ-131" //MQ131
|
||||
#define ADC_Bit_Resolution 10 // For arduino UNO/MEGA/NANO
|
||||
#define RatioMQ131CleanAir 15 //RS / R0 = 15 ppm
|
||||
//#define calibration_button 13 //Pin to calibrate your sensor
|
||||
|
||||
//Declare Sensor
|
||||
@ -47,8 +48,28 @@ void setup() {
|
||||
O3 | 23.943 | -1.11
|
||||
*/
|
||||
|
||||
// Calibration setup
|
||||
MQ131.setR0(385.40);
|
||||
|
||||
/***************************** 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.");
|
||||
int calcR0 = 0;
|
||||
for(int i = 0; i<=10; i ++)
|
||||
{
|
||||
MQ131.update(); // Update data, the arduino will be read the voltage on the analog pin
|
||||
calcR0 += MQ131.calibrate(RatioMQ131CleanAir);
|
||||
Serial.print(".");
|
||||
}
|
||||
MQ131.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 ********************************************/
|
||||
|
||||
/*
|
||||
//If the RL value is different from 10K please assign your RL value with the following method:
|
||||
|
@ -26,6 +26,7 @@
|
||||
#define pin A0 //Analog input 0 of your arduino
|
||||
#define type "MQ-135" //MQ135
|
||||
#define ADC_Bit_Resolution 10 // For arduino UNO/MEGA/NANO
|
||||
#define RatioMQ135CleanAir 3.6//RS / R0 = 3.6 ppm
|
||||
//#define calibration_button 13 //Pin to calibrate your sensor
|
||||
|
||||
//Declare Sensor
|
||||
@ -50,8 +51,28 @@ void setup() {
|
||||
Acetona | 34.668 | -3.369
|
||||
*/
|
||||
|
||||
// Calibration setup
|
||||
MQ135.setR0(76.63);
|
||||
|
||||
/***************************** 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.");
|
||||
int calcR0 = 0;
|
||||
for(int i = 0; i<=10; i ++)
|
||||
{
|
||||
MQ135.update(); // Update data, the arduino will be read the voltage on the analog pin
|
||||
calcR0 += MQ135.calibrate(RatioMQ135CleanAir);
|
||||
Serial.print(".");
|
||||
}
|
||||
MQ135.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 ********************************************/
|
||||
|
||||
/*
|
||||
//If the RL value is different from 10K please assign your RL value with the following method:
|
||||
|
@ -26,7 +26,7 @@
|
||||
#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 calibration_button 13 //Pin to calibrate your sensor
|
||||
#define RatioMQ2CleanAir 9.83 //RS / R0 = 9.83 ppm
|
||||
|
||||
//Declare Sensor
|
||||
MQUnifiedsensor MQ2(placa, Voltage_Resolution, ADC_Bit_Resolution, pin, type);
|
||||
@ -48,9 +48,27 @@ void setup() {
|
||||
Propane| 658.71 | -2.168
|
||||
*/
|
||||
|
||||
// Calibration setup
|
||||
MQ2.setR0(9.659574468);
|
||||
/***************************** 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.");
|
||||
int calcR0 = 0;
|
||||
for(int i = 0; i<=10; i ++)
|
||||
{
|
||||
MQ2.update(); // Update data, the arduino will be read the voltage on the analog pin
|
||||
calcR0 += MQ2.calibrate(RatioMQ2CleanAir);
|
||||
Serial.print(".");
|
||||
}
|
||||
MQ2.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 ********************************************/
|
||||
/*
|
||||
//If the RL value is different from 10K please assign your RL value with the following method:
|
||||
MQ2.setRL(10);
|
||||
|
@ -26,6 +26,7 @@
|
||||
#define pin A0 //Analog input 0 of your arduino
|
||||
#define type "MQ-3" //MQ3
|
||||
#define ADC_Bit_Resolution 10 // For arduino UNO/MEGA/NANO
|
||||
#define RatioMQ3CleanAir 60 //RS / R0 = 60 ppm
|
||||
//#define calibration_button 13 //Pin to calibrate your sensor
|
||||
|
||||
//Declare Sensor
|
||||
@ -49,8 +50,28 @@ void setup() {
|
||||
Hexane | 7585.3 | -2.849
|
||||
*/
|
||||
|
||||
// Calibration setup
|
||||
MQ3.setR0(3.86018237);
|
||||
|
||||
/***************************** 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.");
|
||||
int calcR0 = 0;
|
||||
for(int i = 0; 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 ********************************************/
|
||||
|
||||
/*
|
||||
//If the RL value is different from 10K please assign your RL value with the following method:
|
||||
|
@ -26,6 +26,7 @@
|
||||
#define pin A0 //Analog input 0 of your arduino
|
||||
#define type "MQ-303" //MQ303
|
||||
#define ADC_Bit_Resolution 10 // For arduino UNO/MEGA/NANO
|
||||
#define RatioMQ303CleanAir 1 //RS / R0 = 1 ppm
|
||||
//#define calibration_button 13 //Pin to calibrate your sensor
|
||||
|
||||
//Declare Sensor
|
||||
@ -47,8 +48,28 @@ void setup() {
|
||||
Ethanol | 3.4916 | -2.432
|
||||
*/
|
||||
|
||||
// Calibration setup
|
||||
MQ303.setR0(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.");
|
||||
int calcR0 = 0;
|
||||
for(int i = 0; i<=10; i ++)
|
||||
{
|
||||
MQ303.update(); // Update data, the arduino will be read the voltage on the analog pin
|
||||
calcR0 += MQ303.calibrate(RatioMQ303CleanAir);
|
||||
Serial.print(".");
|
||||
}
|
||||
MQ303.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 ********************************************/
|
||||
|
||||
/*
|
||||
//If the RL value is different from 10K please assign your RL value with the following method:
|
||||
|
@ -26,6 +26,7 @@
|
||||
#define pin A0 //Analog input 0 of your arduino
|
||||
#define type "MQ-309" //MQ309
|
||||
#define ADC_Bit_Resolution 10 // For arduino UNO/MEGA/NANO
|
||||
#define RatioMQ309CleanAir 11 //RS / R0 = 11 ppm
|
||||
//#define calibration_button 13 //Pin to calibrate your sensor
|
||||
|
||||
//Declare Sensor
|
||||
@ -48,8 +49,28 @@ void setup() {
|
||||
ALCOHOL | 473622 | -3.647
|
||||
*/
|
||||
|
||||
// Calibration setup
|
||||
MQ309.setR0(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.");
|
||||
int calcR0 = 0;
|
||||
for(int i = 0; i<=10; i ++)
|
||||
{
|
||||
MQ309.update(); // Update data, the arduino will be read the voltage on the analog pin
|
||||
calcR0 += MQ309.calibrate(RatioMQ309CleanAir);
|
||||
Serial.print(".");
|
||||
}
|
||||
MQ309.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 ********************************************/
|
||||
|
||||
/*
|
||||
//If the RL value is different from 10K please assign your RL value with the following method:
|
||||
|
@ -26,6 +26,7 @@
|
||||
#define pin A0 //Analog input 0 of your arduino
|
||||
#define type "MQ-4" //MQ4
|
||||
#define ADC_Bit_Resolution 10 // For arduino UNO/MEGA/NANO
|
||||
#define RatioMQ4CleanAir 4.4 //RS / R0 = 4.4 ppm
|
||||
//#define calibration_button 13 //Pin to calibrate your sensor
|
||||
|
||||
//Declare Sensor
|
||||
@ -49,8 +50,28 @@ void setup() {
|
||||
*/
|
||||
|
||||
|
||||
// Calibration setup
|
||||
MQ4.setR0(3.86018237);
|
||||
|
||||
/***************************** 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.");
|
||||
int calcR0 = 0;
|
||||
for(int i = 0; i<=10; i ++)
|
||||
{
|
||||
MQ4.update(); // Update data, the arduino will be read the voltage on the analog pin
|
||||
calcR0 += MQ4.calibrate(RatioMQ4CleanAir);
|
||||
Serial.print(".");
|
||||
}
|
||||
MQ4.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 ********************************************/
|
||||
|
||||
/*
|
||||
//If the RL value is different from 10K please assign your RL value with the following method:
|
||||
|
@ -26,6 +26,7 @@
|
||||
#define pin A0 //Analog input 0 of your arduino
|
||||
#define type "MQ-5" //MQ5
|
||||
#define ADC_Bit_Resolution 10 // For arduino UNO/MEGA/NANO
|
||||
#define RatioMQ5CleanAir 6.5 //RS / R0 = 6.5 ppm
|
||||
//#define calibration_button 13 //Pin to calibrate your sensor
|
||||
|
||||
//Declare Sensor
|
||||
@ -48,8 +49,28 @@ void setup() {
|
||||
Alcohol| 97124 | -4.918
|
||||
*/
|
||||
|
||||
// Calibration setup
|
||||
MQ5.setR0(71.100304);
|
||||
|
||||
/***************************** 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.");
|
||||
int calcR0 = 0;
|
||||
for(int i = 0; i<=10; i ++)
|
||||
{
|
||||
MQ5.update(); // Update data, the arduino will be read the voltage on the analog pin
|
||||
calcR0 += MQ5.calibrate(RatioMQ5CleanAir);
|
||||
Serial.print(".");
|
||||
}
|
||||
MQ5.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 ********************************************/
|
||||
|
||||
/*
|
||||
//If the RL value is different from 10K please assign your RL value with the following method:
|
||||
|
@ -26,6 +26,7 @@
|
||||
#define pin A0 //Analog input 0 of your arduino
|
||||
#define type "MQ-6" //MQ6
|
||||
#define ADC_Bit_Resolution 10 // For arduino UNO/MEGA/NANO
|
||||
#define RatioMQ6CleanAir 10 //RS / R0 = 10 ppm
|
||||
//#define calibration_button 13 //Pin to calibrate your sensor
|
||||
|
||||
//Declare Sensor
|
||||
@ -48,9 +49,28 @@ void setup() {
|
||||
Alcohol | 50000000 | -6.017
|
||||
*/
|
||||
|
||||
// Calibration setup
|
||||
MQ6.setR0(13.4285714);
|
||||
|
||||
/***************************** 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.");
|
||||
int calcR0 = 0;
|
||||
for(int i = 0; i<=10; i ++)
|
||||
{
|
||||
MQ6.update(); // Update data, the arduino will be read the voltage on the analog pin
|
||||
calcR0 += MQ6.calibrate(RatioMQ6CleanAir);
|
||||
Serial.print(".");
|
||||
}
|
||||
MQ6.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 ********************************************/
|
||||
/*
|
||||
//If the RL value is different from 10K please assign your RL value with the following method:
|
||||
MQ6.setRL(10);
|
||||
|
@ -26,6 +26,7 @@
|
||||
#define pin A0 //Analog input 0 of your arduino
|
||||
#define type "MQ-7" //MQ7
|
||||
#define ADC_Bit_Resolution 10 // For arduino UNO/MEGA/NANO
|
||||
#define RatioMQ7CleanAir 27.5 //RS / R0 = 27.5 ppm
|
||||
//#define calibration_button 13 //Pin to calibrate your sensor
|
||||
|
||||
//Declare Sensor
|
||||
@ -49,8 +50,28 @@ void setup() {
|
||||
Alcohol | 40000000000000000 | -12.35
|
||||
*/
|
||||
|
||||
// Calibration setup
|
||||
MQ7.setR0(4);
|
||||
|
||||
/***************************** 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.");
|
||||
int calcR0 = 0;
|
||||
for(int i = 0; i<=10; i ++)
|
||||
{
|
||||
MQ7.update(); // Update data, the arduino will be read the voltage on the analog pin
|
||||
calcR0 += MQ7.calibrate(RatioMQ7CleanAir);
|
||||
Serial.print(".");
|
||||
}
|
||||
MQ7.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 ********************************************/
|
||||
|
||||
/*
|
||||
//If the RL value is different from 10K please assign your RL value with the following method:
|
||||
|
@ -26,6 +26,7 @@
|
||||
#define pin A0 //Analog input 0 of your arduino
|
||||
#define type "MQ-8" //MQ8
|
||||
#define ADC_Bit_Resolution 10 // For arduino UNO/MEGA/NANO
|
||||
#define RatioMQ8CleanAir 70 //RS / R0 = 70 ppm
|
||||
//#define calibration_button 13 //Pin to calibrate your sensor
|
||||
|
||||
//Declare Sensor
|
||||
@ -49,9 +50,28 @@ void setup() {
|
||||
Alcohol | 76101 | -1.86
|
||||
*/
|
||||
|
||||
// Calibration setup
|
||||
MQ8.setR0(1);
|
||||
|
||||
/***************************** 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.");
|
||||
int calcR0 = 0;
|
||||
for(int i = 0; i<=10; i ++)
|
||||
{
|
||||
MQ8.update(); // Update data, the arduino will be read the voltage on the analog pin
|
||||
calcR0 += MQ8.calibrate(RatioMQ8CleanAir);
|
||||
Serial.print(".");
|
||||
}
|
||||
MQ8.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 ********************************************/
|
||||
/*
|
||||
//If the RL value is different from 10K please assign your RL value with the following method:
|
||||
MQ8.setRL(10);
|
||||
|
@ -26,6 +26,7 @@
|
||||
#define pin A0 //Analog input 0 of your arduino
|
||||
#define type "MQ-9" //MQ9
|
||||
#define ADC_Bit_Resolution 10 // For arduino UNO/MEGA/NANO
|
||||
#define RatioMQ9CleanAir 9.6 //RS / R0 = 9.6 ppm
|
||||
//#define calibration_button 13 //Pin to calibrate your sensor
|
||||
|
||||
//Declare Sensor
|
||||
@ -47,8 +48,28 @@ void setup() {
|
||||
CO | 599.65 | -2.244
|
||||
*/
|
||||
|
||||
// Calibration setup
|
||||
MQ9.setR0(9.42857143);
|
||||
|
||||
/***************************** 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.");
|
||||
int calcR0 = 0;
|
||||
for(int i = 0; i<=10; i ++)
|
||||
{
|
||||
MQ9.update(); // Update data, the arduino will be read the voltage on the analog pin
|
||||
calcR0 += MQ9.calibrate(RatioMQ9CleanAir);
|
||||
Serial.print(".");
|
||||
}
|
||||
MQ9.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 ********************************************/
|
||||
|
||||
/*
|
||||
//If the RL value is different from 10K please assign your RL value with the following method:
|
||||
|
Loading…
x
Reference in New Issue
Block a user