From c7b67d7fa5ea2518e7b75b01c2540bc1c886a65f Mon Sep 17 00:00:00 2001 From: miguel5612 Date: Mon, 30 Mar 2020 18:40:55 -0500 Subject: [PATCH] Updated examples --- examples/Alcoholimeter/Alcoholimeter.ino | 24 +++++++-------- examples/AlgorithmTester/AlgorithmTester.ino | 31 ++++++++++++-------- examples/Calibration/Calibration.ino | 24 +++++++-------- examples/ESP8266/ESP8266.ino | 19 ++++++------ examples/MQ-2/MQ-2.ino | 21 ++++++------- examples/MQ-3/MQ-3.ino | 21 +++++++------ examples/MQ-4-ALL/MQ-4-ALL.ino | 21 +++++++------ examples/MQ-4-LINEAR/MQ-4-LINEAR.ino | 21 +++++++------ examples/MQ-4/MQ-4.ino | 21 +++++++------ examples/MQ-9-ALL/MQ-9-ALL.ino | 21 +++++++------ examples/MQ-9/MQ-9.ino | 21 +++++++------ 11 files changed, 123 insertions(+), 122 deletions(-) diff --git a/examples/Alcoholimeter/Alcoholimeter.ino b/examples/Alcoholimeter/Alcoholimeter.ino index 8ec7f7f..37cfc1c 100644 --- a/examples/Alcoholimeter/Alcoholimeter.ino +++ b/examples/Alcoholimeter/Alcoholimeter.ino @@ -23,18 +23,18 @@ //Include the library #include +/************************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 -#define placa "Arduino UNO" -#define Voltage_Resolution 5 -#define pin A3 //Analog input 3 of your arduino -#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); +/*****************************Globals***********************************************/ +double alcoholPPM = (0); +/**************************Object_Sensor********************************************/ +MQUnifiedsensor MQ3(Board, Voltage_Resolution, ADC_Bit_Resolution, Pin, Type); void setup() { //Init the serial port communication - to debug the library @@ -45,7 +45,7 @@ void setup() { MQ3.setA(0.3934); MQ3.setB(-1.504); // Configurate the ecuation values to get Alcohol concentration /* Exponential regression: - Gas | a | b + Gas | a | b LPG | 44771 | -3.245 CH4 | 2*10^31| 19.01 CO | 521853 | -3.821 diff --git a/examples/AlgorithmTester/AlgorithmTester.ino b/examples/AlgorithmTester/AlgorithmTester.ino index 4ed55f1..8c4ba80 100644 --- a/examples/AlgorithmTester/AlgorithmTester.ino +++ b/examples/AlgorithmTester/AlgorithmTester.ino @@ -13,20 +13,25 @@ with which the library was made. */ -//Definitions -#define placa "Arduino Mega 2560" -#define Voltage_Resolution 5 -#define type "Algorithm Tester" -#define ADC_Bit_Resolution 10 // For arduino UNO/MEGA/NANO -// On this program pin value doesn't matter -#define pin2 A2 //Analog input 2 of your arduino -//Declare Sensor -MQUnifiedsensor mySensor(placa, Voltage_Resolution, ADC_Bit_Resolution, pin2, type); +//Include the library +#include +/************************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 -double ratio[4] = {}; -double expectedValue[4] = {}; -double calculatedValues[4] = {}; -double error[4] = {}; +//Declare Sensor +MQUnifiedsensor mySensor(Board, Voltage_Resolution, ADC_Bit_Resolution, Pin, Type); + +/*****************************Globals***********************************************/ +double ratio[4] = {}; +double expectedValue[4] = {}; +double calculatedValues[4] = {}; +double error[4] = {}; +/**************************Object_Sensor********************************************/ void setup() { diff --git a/examples/Calibration/Calibration.ino b/examples/Calibration/Calibration.ino index 048d199..426bf66 100644 --- a/examples/Calibration/Calibration.ino +++ b/examples/Calibration/Calibration.ino @@ -15,15 +15,16 @@ //Include the library #include +/************************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 -#define placa "Arduino UNO" -#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 - - +/*****************************Globals***********************************************/ +double alcoholPPM = (0); //Defaults, uncomment if you need #define RatioMQ2CleanAir 9.83 //RS / R0 = 9.83 ppm //#define RatioMQ3CleanAir 60 //RS / R0 = 60 ppm @@ -37,11 +38,10 @@ //#define RatioMQ135CleanAir 3.6//RS / R0 = 3.6 ppm //#define RatioMQ303CleanAir 1 //RS / R0 = 1 ppm //#define RatioMQ309CleanAir 11 //RS / R0 = 11 ppm - -//Declare Sensor - -MQUnifiedsensor MQ2(placa, Voltage_Resolution, ADC_Bit_Resolution, pin, type); unsigned long contador = 0; +/**************************Object_Sensor********************************************/ + +MQUnifiedsensor MQ2(Board, Voltage_Resolution, ADC_Bit_Resolution, Pin, Type); void setup() { //Init serial port diff --git a/examples/ESP8266/ESP8266.ino b/examples/ESP8266/ESP8266.ino index 45568cf..fb51732 100644 --- a/examples/ESP8266/ESP8266.ino +++ b/examples/ESP8266/ESP8266.ino @@ -22,16 +22,17 @@ //Include the library #include +/************************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 -#define placa "ESP8266" //NodeMcu, WeMos D1, TTGo, ESP32.. etc -#define Voltage_Resolution 3.3 -#define pin A0 //Analog input 0 of your ESP Board -#define type "MQ-3" //MQ3 -#define ADC_Bit_Resolution 10 // For ESP8266 - -//Declare Sensor -MQUnifiedsensor MQ3(placa, Voltage_Resolution, ADC_Bit_Resolution, pin, type); +/*****************************Globals***********************************************/ +MQUnifiedsensor MQ3(Board, Voltage_Resolution, ADC_Bit_Resolution, Pin, Type); +/*****************************Globals***********************************************/ void setup() { //Init the serial port communication - to debug the library diff --git a/examples/MQ-2/MQ-2.ino b/examples/MQ-2/MQ-2.ino index eed2f85..43dc052 100644 --- a/examples/MQ-2/MQ-2.ino +++ b/examples/MQ-2/MQ-2.ino @@ -22,17 +22,18 @@ //Include the library #include +/************************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 -#define placa "Arduino UNO" -#define Voltage_Resolution 5 -#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); +/*****************************Globals***********************************************/ +MQUnifiedsensor MQ2(Board, Voltage_Resolution, ADC_Bit_Resolution, Pin, Type); +/*****************************Globals***********************************************/ void setup() { //Init the serial port communication - to debug the library diff --git a/examples/MQ-3/MQ-3.ino b/examples/MQ-3/MQ-3.ino index a3be6e0..3c02dd1 100644 --- a/examples/MQ-3/MQ-3.ino +++ b/examples/MQ-3/MQ-3.ino @@ -23,18 +23,17 @@ //Include the library #include - -//Definitions -#define placa "Arduino UNO" -#define Voltage_Resolution 5 -#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 - +/************************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 +#define RatioMQ3CleanAir (60) //RS / R0 = 60 ppm +/*****************************Globals***********************************************/ //Declare Sensor -MQUnifiedsensor MQ3(placa, Voltage_Resolution, ADC_Bit_Resolution, pin, type); +MQUnifiedsensor MQ3(Board, Voltage_Resolution, ADC_Bit_Resolution, Pin, Type); void setup() { //Init the serial port communication - to debug the library diff --git a/examples/MQ-4-ALL/MQ-4-ALL.ino b/examples/MQ-4-ALL/MQ-4-ALL.ino index 72df558..f42fb13 100644 --- a/examples/MQ-4-ALL/MQ-4-ALL.ino +++ b/examples/MQ-4-ALL/MQ-4-ALL.ino @@ -23,18 +23,17 @@ //Include the library #include - -//Definitions -#define placa "Arduino UNO" -#define Voltage_Resolution 5 -#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 - +/************************Hardware Related Macros************************************/ +#define Board ("Arduino UNO") +#define Pin (A4) //Analog input 4 of your arduino +/***********************Software Related Macros************************************/ +#define Type ("MQ-4") //MQ4 +#define Voltage_Resolution (5) +#define ADC_Bit_Resolution (10) // For arduino UNO/MEGA/NANO +#define RatioMQ4CleanAir (4.4) //RS / R0 = 60 ppm +/*****************************Globals***********************************************/ //Declare Sensor -MQUnifiedsensor MQ4(placa, Voltage_Resolution, ADC_Bit_Resolution, pin, type); +MQUnifiedsensor MQ4(Board, Voltage_Resolution, ADC_Bit_Resolution, Pin, Type); void setup() { //Init the serial port communication - to debug the library diff --git a/examples/MQ-4-LINEAR/MQ-4-LINEAR.ino b/examples/MQ-4-LINEAR/MQ-4-LINEAR.ino index 3b98e68..cee7235 100644 --- a/examples/MQ-4-LINEAR/MQ-4-LINEAR.ino +++ b/examples/MQ-4-LINEAR/MQ-4-LINEAR.ino @@ -23,18 +23,17 @@ //Include the library #include - -//Definitions -#define placa "Arduino UNO" -#define Voltage_Resolution 5 -#define pin A4 //Analog input 4 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 - +/************************Hardware Related Macros************************************/ +#define Board ("Arduino UNO") +#define Pin (A4) //Analog input 4 of your arduino +/***********************Software Related Macros************************************/ +#define Type ("MQ-4") //MQ4 +#define Voltage_Resolution (5) +#define ADC_Bit_Resolution (10) // For arduino UNO/MEGA/NANO +#define RatioMQ4CleanAir (4.4) //RS / R0 = 60 ppm +/*****************************Globals***********************************************/ //Declare Sensor -MQUnifiedsensor MQ4(placa, Voltage_Resolution, ADC_Bit_Resolution, pin, type); +MQUnifiedsensor MQ4(Board, Voltage_Resolution, ADC_Bit_Resolution, Pin, Type); void setup() { //Init the serial port communication - to debug the library diff --git a/examples/MQ-4/MQ-4.ino b/examples/MQ-4/MQ-4.ino index 310f2f4..88ba024 100644 --- a/examples/MQ-4/MQ-4.ino +++ b/examples/MQ-4/MQ-4.ino @@ -23,18 +23,17 @@ //Include the library #include - -//Definitions -#define placa "Arduino UNO" -#define Voltage_Resolution 5 -#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 - +/************************Hardware Related Macros************************************/ +#define Board ("Arduino UNO") +#define Pin (A4) //Analog input 4 of your arduino +/***********************Software Related Macros************************************/ +#define Type ("MQ-4") //MQ4 +#define Voltage_Resolution (5) +#define ADC_Bit_Resolution (10) // For arduino UNO/MEGA/NANO +#define RatioMQ4CleanAir (4.4) //RS / R0 = 60 ppm +/*****************************Globals***********************************************/ //Declare Sensor -MQUnifiedsensor MQ4(placa, Voltage_Resolution, ADC_Bit_Resolution, pin, type); +MQUnifiedsensor MQ4(Board, Voltage_Resolution, ADC_Bit_Resolution, Pin, Type); void setup() { //Init the serial port communication - to debug the library diff --git a/examples/MQ-9-ALL/MQ-9-ALL.ino b/examples/MQ-9-ALL/MQ-9-ALL.ino index 3976407..b476f29 100644 --- a/examples/MQ-9-ALL/MQ-9-ALL.ino +++ b/examples/MQ-9-ALL/MQ-9-ALL.ino @@ -23,18 +23,17 @@ //Include the library #include - -//Definitions -#define placa "Arduino UNO" -#define Voltage_Resolution 5 -#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 - +/************************Hardware Related Macros************************************/ +#define Board ("Arduino UNO") +#define Pin (A9) //Analog input 4 of your arduino +/***********************Software Related Macros************************************/ +#define Type ("MQ-9") //MQ9 +#define Voltage_Resolution (5) +#define ADC_Bit_Resolution (10) // For arduino UNO/MEGA/NANO +#define RatioMQ9CleanAir (9.6) //RS / R0 = 60 ppm +/*****************************Globals***********************************************/ //Declare Sensor -MQUnifiedsensor MQ9(placa, Voltage_Resolution, ADC_Bit_Resolution, pin, type); +MQUnifiedsensor MQ9(Board, Voltage_Resolution, ADC_Bit_Resolution, Pin, Type); void setup() { //Init the serial port communication - to debug the library diff --git a/examples/MQ-9/MQ-9.ino b/examples/MQ-9/MQ-9.ino index 8d8e4fb..0f44bd8 100644 --- a/examples/MQ-9/MQ-9.ino +++ b/examples/MQ-9/MQ-9.ino @@ -23,18 +23,17 @@ //Include the library #include - -//Definitions -#define placa "Arduino UNO" -#define Voltage_Resolution 5 -#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 - +/************************Hardware Related Macros************************************/ +#define Board ("Arduino UNO") +#define Pin (A9) //Analog input 4 of your arduino +/***********************Software Related Macros************************************/ +#define Type ("MQ-9") //MQ9 +#define Voltage_Resolution (5) +#define ADC_Bit_Resolution (10) // For arduino UNO/MEGA/NANO +#define RatioMQ9CleanAir (9.6) //RS / R0 = 60 ppm +/*****************************Globals***********************************************/ //Declare Sensor -MQUnifiedsensor MQ9(placa, Voltage_Resolution, ADC_Bit_Resolution, pin, type); +MQUnifiedsensor MQ9(Board, Voltage_Resolution, ADC_Bit_Resolution, Pin, Type); void setup() { //Init the serial port communication - to debug the library