Updated examples

This commit is contained in:
miguel5612 2020-03-30 18:40:55 -05:00
parent 6b3c764b71
commit c7b67d7fa5
11 changed files with 123 additions and 122 deletions

View File

@ -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
@ -45,7 +45,7 @@ void setup() {
MQ3.setA(0.3934); MQ3.setB(-1.504); // Configurate the ecuation values to get Alcohol concentration MQ3.setA(0.3934); MQ3.setB(-1.504); // Configurate the ecuation values to get Alcohol concentration
/* /*
Exponential regression: Exponential regression:
Gas | a | b Gas | a | b
LPG | 44771 | -3.245 LPG | 44771 | -3.245
CH4 | 2*10^31| 19.01 CH4 | 2*10^31| 19.01
CO | 521853 | -3.821 CO | 521853 | -3.821

View File

@ -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
double ratio[4] = {}; //Declare Sensor
double expectedValue[4] = {}; MQUnifiedsensor mySensor(Board, Voltage_Resolution, ADC_Bit_Resolution, Pin, Type);
double calculatedValues[4] = {};
double error[4] = {}; /*****************************Globals***********************************************/
double ratio[4] = {};
double expectedValue[4] = {};
double calculatedValues[4] = {};
double error[4] = {};
/**************************Object_Sensor********************************************/
void setup() void setup()
{ {

View File

@ -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,11 +38,10 @@
//#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

View File

@ -22,16 +22,17 @@
//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 "ESP8266" //NodeMcu, WeMos D1, TTGo, ESP32.. etc MQUnifiedsensor MQ3(Board, Voltage_Resolution, ADC_Bit_Resolution, Pin, Type);
#define Voltage_Resolution 3.3 /*****************************Globals***********************************************/
#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);
void setup() { void setup() {
//Init the serial port communication - to debug the library //Init the serial port communication - to debug the library

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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