mirror of
https://github.com/miguel5612/MQSensorsLib.git
synced 2025-03-15 05:17:30 +03:00
Updated examples
This commit is contained in:
parent
6b3c764b71
commit
c7b67d7fa5
@ -23,18 +23,18 @@
|
||||
|
||||
//Include the library
|
||||
#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
|
||||
#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
|
||||
|
@ -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 <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
|
||||
|
||||
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()
|
||||
{
|
||||
|
@ -15,15 +15,16 @@
|
||||
|
||||
//Include the library
|
||||
#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
|
||||
#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
|
||||
|
@ -22,16 +22,17 @@
|
||||
|
||||
//Include the library
|
||||
#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
|
||||
#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
|
||||
|
@ -22,17 +22,18 @@
|
||||
|
||||
//Include the library
|
||||
#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
|
||||
#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
|
||||
|
@ -23,18 +23,17 @@
|
||||
|
||||
//Include the library
|
||||
#include <MQUnifiedsensor.h>
|
||||
|
||||
//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
|
||||
|
@ -23,18 +23,17 @@
|
||||
|
||||
//Include the library
|
||||
#include <MQUnifiedsensor.h>
|
||||
|
||||
//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
|
||||
|
@ -23,18 +23,17 @@
|
||||
|
||||
//Include the library
|
||||
#include <MQUnifiedsensor.h>
|
||||
|
||||
//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
|
||||
|
@ -23,18 +23,17 @@
|
||||
|
||||
//Include the library
|
||||
#include <MQUnifiedsensor.h>
|
||||
|
||||
//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
|
||||
|
@ -23,18 +23,17 @@
|
||||
|
||||
//Include the library
|
||||
#include <MQUnifiedsensor.h>
|
||||
|
||||
//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
|
||||
|
@ -23,18 +23,17 @@
|
||||
|
||||
//Include the library
|
||||
#include <MQUnifiedsensor.h>
|
||||
|
||||
//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
|
||||
|
Loading…
x
Reference in New Issue
Block a user