From 1d4ad83f2264333dd0250d005a7adc0662d35494 Mon Sep 17 00:00:00 2001 From: miguel5612 Date: Thu, 15 Aug 2019 09:02:38 -0500 Subject: [PATCH] Updated examples, added calibration option into program Commented --- examples/MQ-131/MQ-131.ino | 10 ++++++++++ examples/MQ-135/MQ-135.ino | 10 ++++++++++ examples/MQ-2/MQ-2.ino | 10 ++++++++++ examples/MQ-3/MQ-3.ino | 10 ++++++++++ examples/MQ-303A/MQ303.ino | 10 ++++++++++ examples/MQ-309A/MQ-309.ino | 11 +++++++++++ examples/MQ-4/MQ-4.ino | 10 ++++++++++ examples/MQ-5/MQ-5.ino | 10 ++++++++++ examples/MQ-6/MQ-6.ino | 10 ++++++++++ examples/MQ-7/MQ-7.ino | 10 ++++++++++ examples/MQ-8/MQ-8.ino | 10 ++++++++++ examples/MQ-9/MQ-9.ino | 10 ++++++++++ examples/MQ-Board/MQ-Board.ino | 25 ++++++++++++++++++++++++- 13 files changed, 145 insertions(+), 1 deletion(-) diff --git a/examples/MQ-131/MQ-131.ino b/examples/MQ-131/MQ-131.ino index 5a17e04..67b28f2 100644 --- a/examples/MQ-131/MQ-131.ino +++ b/examples/MQ-131/MQ-131.ino @@ -19,6 +19,7 @@ //Definitions #define pin A0 //Analog input 0 of your arduino #define type 131 //MQ131 +//#define calibration_button 13 //Pin to calibrate your sensor //Declare Sensor MQUnifiedsensor MQ131(pin, type); @@ -35,10 +36,19 @@ void setup() { Remarks: This function create the sensor object. ************************************************************************************/ MQ131.inicializar(); + //pinMode(calibration_button, INPUT); } void loop() { MQ131.update(); // Update data, the arduino will be read the voltaje in the analog pin + /* + //Rutina de calibracion - Uncomment if you need (setup too and header) + if(calibration_button) + { + float R0 = MQ131.calibrate(); + MQ131.setR0(R0): + } + */ /***************************** MQReadSensor **************************************** Input: Gas - Serial print flag Output: Value in PPM diff --git a/examples/MQ-135/MQ-135.ino b/examples/MQ-135/MQ-135.ino index 7943c30..0f6548d 100644 --- a/examples/MQ-135/MQ-135.ino +++ b/examples/MQ-135/MQ-135.ino @@ -19,6 +19,7 @@ //Definitions #define pin A0 //Analog input 0 of your arduino #define type 135 //MQ135 +//#define calibration_button 13 //Pin to calibrate your sensor //Declare Sensor MQUnifiedsensor MQ135(pin, type); @@ -35,10 +36,19 @@ void setup() { Remarks: This function create the sensor object. ************************************************************************************/ MQ135.inicializar(); + //pinMode(calibration_button, INPUT); } void loop() { MQ135.update(); // Update data, the arduino will be read the voltaje in the analog pin + /* + //Rutina de calibracion - Uncomment if you need (setup too and header) + if(calibration_button) + { + float R0 = MQ135.calibrate(); + MQ135.setR0(R0): + } + */ /***************************** MQReadSensor **************************************** Input: Gas - Serial print flag Output: Value in PPM diff --git a/examples/MQ-2/MQ-2.ino b/examples/MQ-2/MQ-2.ino index 46a1772..e25ed9d 100644 --- a/examples/MQ-2/MQ-2.ino +++ b/examples/MQ-2/MQ-2.ino @@ -19,6 +19,7 @@ //Definitions #define pin A0 //Analog input 0 of your arduino #define type 2 //MQ2 +//#define calibration_button 13 //Pin to calibrate your sensor //Declare Sensor MQUnifiedsensor MQ2(pin, type); @@ -35,10 +36,19 @@ void setup() { ************************************************************************************/ //init the sensor MQ2.inicializar(); + //pinMode(calibration_button, INPUT); } void loop() { MQ2.update(); // Update data, the arduino will be read the voltaje in the analog pin + /* + //Rutina de calibracion - Uncomment if you need (setup too and header) + if(calibration_button) + { + float R0 = MQ2.calibrate(); + MQ2.setR0(R0): + } + */ /***************************** MQReadSensor **************************************** Input: Gas - Serial print flag Output: Value in PPM diff --git a/examples/MQ-3/MQ-3.ino b/examples/MQ-3/MQ-3.ino index 3116e35..d7470fd 100644 --- a/examples/MQ-3/MQ-3.ino +++ b/examples/MQ-3/MQ-3.ino @@ -19,6 +19,7 @@ //Definitions #define pin A0 //Analog input 0 of your arduino #define type 3 //MQ3 +//#define calibration_button 13 //Pin to calibrate your sensor //Declare Sensor MQUnifiedsensor MQ3(pin, type); @@ -35,10 +36,19 @@ void setup() { Remarks: This function create the sensor object. ************************************************************************************/ MQ3.inicializar(); + //pinMode(calibration_button, INPUT); } void loop() { MQ3.update(); // Update data, the arduino will be read the voltaje in the analog pin + /* + //Rutina de calibracion - Uncomment if you need (setup too and header) + if(calibration_button) + { + float R0 = MQ3.calibrate(); + MQ3.setR0(R0): + } + */ /***************************** MQReadSensor **************************************** Input: Gas - Serial print flag Output: Value in PPM diff --git a/examples/MQ-303A/MQ303.ino b/examples/MQ-303A/MQ303.ino index eb15f7d..eaae2e4 100644 --- a/examples/MQ-303A/MQ303.ino +++ b/examples/MQ-303A/MQ303.ino @@ -19,6 +19,7 @@ //Definitions #define pin A0 //Analog input 0 of your arduino #define type 303 //MQ303 +//#define calibration_button 13 //Pin to calibrate your sensor //Declare Sensor MQUnifiedsensor MQ303(pin, type); @@ -35,10 +36,19 @@ void setup() { Remarks: This function create the sensor object. ************************************************************************************/ MQ303.inicializar(); + //pinMode(calibration_button, INPUT); } void loop() { MQ303.update(); + /* + //Rutina de calibracion - Uncomment if you need (setup too and header) + if(calibration_button) + { + float R0 = MQ303.calibrate(); + MQ303.setR0(R0): + } + */ /***************************** MQReadSensor **************************************** Input: Gas - Serial print flag Output: Value in PPM diff --git a/examples/MQ-309A/MQ-309.ino b/examples/MQ-309A/MQ-309.ino index 03acf13..fd0775b 100644 --- a/examples/MQ-309A/MQ-309.ino +++ b/examples/MQ-309A/MQ-309.ino @@ -19,6 +19,7 @@ //Definitions #define pin A0 //Analog input 0 of your arduino #define type 309 //MQ309 +//#define calibration_button 13 //Pin to calibrate your sensor //Declare Sensor MQUnifiedsensor MQ309(pin, type); @@ -35,9 +36,19 @@ void setup() { Remarks: This function create the sensor object. ************************************************************************************/ MQ309.inicializar(); + //pinMode(calibration_button, INPUT); } void loop() { + MQ309.update(); + /* + //Rutina de calibracion - Uncomment if you need (setup too and header) + if(calibration_button) + { + float R0 = MQ309.calibrate(); + MQ309.setR0(R0): + } + */ /***************************** MQReadSensor **************************************** Input: Gas - Serial print flag Output: Value in PPM diff --git a/examples/MQ-4/MQ-4.ino b/examples/MQ-4/MQ-4.ino index e476be8..f3c9d1a 100644 --- a/examples/MQ-4/MQ-4.ino +++ b/examples/MQ-4/MQ-4.ino @@ -19,6 +19,7 @@ //Definitions #define pin A0 //Analog input 0 of your arduino #define type 4 //MQ4 +//#define calibration_button 13 //Pin to calibrate your sensor //Declare Sensor MQUnifiedsensor MQ4(pin, type); @@ -35,10 +36,19 @@ void setup() { Remarks: This function create the sensor object. ************************************************************************************/ MQ4.inicializar(); + //pinMode(calibration_button, INPUT); } void loop() { MQ4.update(); // Update data, the arduino will be read the voltaje in the analog pin + /* + //Rutina de calibracion - Uncomment if you need (setup too and header) + if(calibration_button) + { + float R0 = MQ4.calibrate(); + MQ4.setR0(R0): + } + */ /***************************** MQReadSensor **************************************** Input: Gas - Serial print flag Output: Value in PPM diff --git a/examples/MQ-5/MQ-5.ino b/examples/MQ-5/MQ-5.ino index 3962726..825a7a2 100644 --- a/examples/MQ-5/MQ-5.ino +++ b/examples/MQ-5/MQ-5.ino @@ -19,6 +19,7 @@ //Definitions #define pin A0 //Analog input 0 of your arduino #define type 5 //MQ5 +//#define calibration_button 13 //Pin to calibrate your sensor //Declare Sensor MQUnifiedsensor MQ5(pin, type); @@ -35,11 +36,20 @@ void setup() { Remarks: This function create the sensor object. ************************************************************************************/ MQ5.inicializar(); + //pinMode(calibration_button, INPUT); } void loop() { MQ5.update(); // Update data, the arduino will be read the voltaje in the analog pin + /* + //Rutina de calibracion - Uncomment if you need (setup too and header) + if(calibration_button) + { + float R0 = MQ5.calibrate(); + MQ5.setR0(R0): + } + */ /***************************** MQReadSensor **************************************** Input: Gas - Serial print flag Output: Value in PPM diff --git a/examples/MQ-6/MQ-6.ino b/examples/MQ-6/MQ-6.ino index a619b1c..1a8bb1d 100644 --- a/examples/MQ-6/MQ-6.ino +++ b/examples/MQ-6/MQ-6.ino @@ -19,6 +19,7 @@ //Definitions #define pin A0 //Analog input 0 of your arduino #define type 6 //MQ6 +//#define calibration_button 13 //Pin to calibrate your sensor //Declare Sensor MQUnifiedsensor MQ6(pin, type); @@ -35,10 +36,19 @@ void setup() { Remarks: This function create the sensor object. ************************************************************************************/ MQ6.inicializar(); + //pinMode(calibration_button, INPUT); } void loop() { MQ6.update(); // Update data, the arduino will be read the voltaje in the analog pin + /* + //Rutina de calibracion - Uncomment if you need (setup too and header) + if(calibration_button) + { + float R0 = MQ6.calibrate(); + MQ6.setR0(R0): + } + */ /***************************** MQReadSensor **************************************** Input: Gas - Serial print flag Output: Value in PPM diff --git a/examples/MQ-7/MQ-7.ino b/examples/MQ-7/MQ-7.ino index 76f76b9..df7cdb7 100644 --- a/examples/MQ-7/MQ-7.ino +++ b/examples/MQ-7/MQ-7.ino @@ -21,6 +21,7 @@ //Definitions #define pin A0 //Analog input 0 of your arduino #define type 7 //MQ7 +//#define calibration_button 13 //Pin to calibrate your sensor //Declare Sensor @@ -38,10 +39,19 @@ void setup() { Remarks: This function create the sensor object. ************************************************************************************/ MQ7.inicializar(); + //pinMode(calibration_button, INPUT); } void loop() { MQ7.update(); // Update data, the arduino will be read the voltaje in the analog pin + /* + //Rutina de calibracion - Uncomment if you need (setup too and header) + if(calibration_button) + { + float R0 = MQ7.calibrate(); + MQ7.setR0(R0): + } + */ /***************************** MQReadSensor **************************************** Input: Gas - Serial print flag Output: Value in PPM diff --git a/examples/MQ-8/MQ-8.ino b/examples/MQ-8/MQ-8.ino index 1070a32..df485f8 100644 --- a/examples/MQ-8/MQ-8.ino +++ b/examples/MQ-8/MQ-8.ino @@ -19,6 +19,7 @@ //Definitions #define pin A0 //Analog input 0 of your arduino #define type 8 //MQ8 +//#define calibration_button 13 //Pin to calibrate your sensor //Declare Sensor MQUnifiedsensor MQ8(pin, type); @@ -35,10 +36,19 @@ void setup() { Remarks: This function create the sensor object. ************************************************************************************/ MQ8.inicializar(); + //pinMode(calibration_button, INPUT); } void loop() { MQ8.update(); // Update data, the arduino will be read the voltaje in the analog pin + /* + //Rutina de calibracion - Uncomment if you need (setup too and header) + if(calibration_button) + { + float R0 = MQ8.calibrate(); + MQ8.setR0(R0): + } + */ /***************************** MQReadSensor **************************************** Input: Gas - Serial print flag Output: Value in PPM diff --git a/examples/MQ-9/MQ-9.ino b/examples/MQ-9/MQ-9.ino index de3358c..275b03a 100644 --- a/examples/MQ-9/MQ-9.ino +++ b/examples/MQ-9/MQ-9.ino @@ -19,6 +19,7 @@ //Definitions #define pin A0 //Analog input 0 of your arduino #define type 9 //MQ9 +//#define calibration_button 13 //Pin to calibrate your sensor //Declare Sensor MQUnifiedsensor MQ9(pin, type); @@ -35,10 +36,19 @@ void setup() { Remarks: This function create the sensor object. ************************************************************************************/ MQ9.inicializar(); + //pinMode(calibration_button, INPUT); } void loop() { MQ9.update(); // Update data, the arduino will be read the voltaje in the analog pin + /* + //Rutina de calibracion - Uncomment if you need (setup too and header) + if(calibration_button) + { + float R0 = MQ9.calibrate(); + MQ9.setR0(R0): + } + */ /***************************** MQReadSensor **************************************** Input: Gas - Serial print flag Output: Value in PPM diff --git a/examples/MQ-Board/MQ-Board.ino b/examples/MQ-Board/MQ-Board.ino index ffcca48..e05fe2a 100644 --- a/examples/MQ-Board/MQ-Board.ino +++ b/examples/MQ-Board/MQ-Board.ino @@ -25,6 +25,7 @@ #define pin7 A7 //Analog input 7 of your arduino #define pin8 A8 //Analog input 8 of your arduino #define pin9 A9 //Analog input 9 of your arduino +//#define calibration_button 13 //Pin to calibrate your sensor //Declare Sensor MQUnifiedsensor MQ2(pin2, 2); @@ -53,6 +54,7 @@ void setup() { MQ9.inicializar(); //Print in serial monitor Serial.print("MQ2 to MQ9 - lecture"); + //pinMode(calibration_button, INPUT); } void loop() { @@ -65,7 +67,28 @@ void loop() { MQ7.update(); MQ8.update(); MQ9.update(); - + /* + //Rutina de calibracion - Uncomment if you need (setup too and header) + if(calibration_button) + { + float R0 = MQ2.calibrate(); + MQ2.setR0(R0): + R0 = MQ3.calibrate(); + MQ3.setR0(R0): + R0 = MQ4.calibrate(); + MQ4.setR0(R0): + R0 = MQ5.calibrate(); + MQ5.setR0(R0): + R0 = MQ6.calibrate(); + MQ6.setR0(R0): + R0 = MQ7.calibrate(); + MQ7.setR0(R0): + R0 = MQ8.calibrate(); + MQ8.setR0(R0): + R0 = MQ9.calibrate(); + MQ9.setR0(R0): + } + */ //Read the sensor and print in serial port LPG = MQ2.readSensor(); Alcohol = MQ3.readSensor();