mirror of
https://github.com/miguel5612/MQSensorsLib.git
synced 2025-03-15 05:17:30 +03:00
Updated examples, added calibration option into program Commented
This commit is contained in:
parent
3ae7b6b1b3
commit
1d4ad83f22
@ -19,6 +19,7 @@
|
|||||||
//Definitions
|
//Definitions
|
||||||
#define pin A0 //Analog input 0 of your arduino
|
#define pin A0 //Analog input 0 of your arduino
|
||||||
#define type 131 //MQ131
|
#define type 131 //MQ131
|
||||||
|
//#define calibration_button 13 //Pin to calibrate your sensor
|
||||||
|
|
||||||
//Declare Sensor
|
//Declare Sensor
|
||||||
MQUnifiedsensor MQ131(pin, type);
|
MQUnifiedsensor MQ131(pin, type);
|
||||||
@ -35,10 +36,19 @@ void setup() {
|
|||||||
Remarks: This function create the sensor object.
|
Remarks: This function create the sensor object.
|
||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
MQ131.inicializar();
|
MQ131.inicializar();
|
||||||
|
//pinMode(calibration_button, INPUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
MQ131.update(); // Update data, the arduino will be read the voltaje in the analog pin
|
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 ****************************************
|
/***************************** MQReadSensor ****************************************
|
||||||
Input: Gas - Serial print flag
|
Input: Gas - Serial print flag
|
||||||
Output: Value in PPM
|
Output: Value in PPM
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
//Definitions
|
//Definitions
|
||||||
#define pin A0 //Analog input 0 of your arduino
|
#define pin A0 //Analog input 0 of your arduino
|
||||||
#define type 135 //MQ135
|
#define type 135 //MQ135
|
||||||
|
//#define calibration_button 13 //Pin to calibrate your sensor
|
||||||
|
|
||||||
//Declare Sensor
|
//Declare Sensor
|
||||||
MQUnifiedsensor MQ135(pin, type);
|
MQUnifiedsensor MQ135(pin, type);
|
||||||
@ -35,10 +36,19 @@ void setup() {
|
|||||||
Remarks: This function create the sensor object.
|
Remarks: This function create the sensor object.
|
||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
MQ135.inicializar();
|
MQ135.inicializar();
|
||||||
|
//pinMode(calibration_button, INPUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
MQ135.update(); // Update data, the arduino will be read the voltaje in the analog pin
|
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 ****************************************
|
/***************************** MQReadSensor ****************************************
|
||||||
Input: Gas - Serial print flag
|
Input: Gas - Serial print flag
|
||||||
Output: Value in PPM
|
Output: Value in PPM
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
//Definitions
|
//Definitions
|
||||||
#define pin A0 //Analog input 0 of your arduino
|
#define pin A0 //Analog input 0 of your arduino
|
||||||
#define type 2 //MQ2
|
#define type 2 //MQ2
|
||||||
|
//#define calibration_button 13 //Pin to calibrate your sensor
|
||||||
|
|
||||||
//Declare Sensor
|
//Declare Sensor
|
||||||
MQUnifiedsensor MQ2(pin, type);
|
MQUnifiedsensor MQ2(pin, type);
|
||||||
@ -35,10 +36,19 @@ void setup() {
|
|||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
//init the sensor
|
//init the sensor
|
||||||
MQ2.inicializar();
|
MQ2.inicializar();
|
||||||
|
//pinMode(calibration_button, INPUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
MQ2.update(); // Update data, the arduino will be read the voltaje in the analog pin
|
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 ****************************************
|
/***************************** MQReadSensor ****************************************
|
||||||
Input: Gas - Serial print flag
|
Input: Gas - Serial print flag
|
||||||
Output: Value in PPM
|
Output: Value in PPM
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
//Definitions
|
//Definitions
|
||||||
#define pin A0 //Analog input 0 of your arduino
|
#define pin A0 //Analog input 0 of your arduino
|
||||||
#define type 3 //MQ3
|
#define type 3 //MQ3
|
||||||
|
//#define calibration_button 13 //Pin to calibrate your sensor
|
||||||
|
|
||||||
//Declare Sensor
|
//Declare Sensor
|
||||||
MQUnifiedsensor MQ3(pin, type);
|
MQUnifiedsensor MQ3(pin, type);
|
||||||
@ -35,10 +36,19 @@ void setup() {
|
|||||||
Remarks: This function create the sensor object.
|
Remarks: This function create the sensor object.
|
||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
MQ3.inicializar();
|
MQ3.inicializar();
|
||||||
|
//pinMode(calibration_button, INPUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
MQ3.update(); // Update data, the arduino will be read the voltaje in the analog pin
|
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 ****************************************
|
/***************************** MQReadSensor ****************************************
|
||||||
Input: Gas - Serial print flag
|
Input: Gas - Serial print flag
|
||||||
Output: Value in PPM
|
Output: Value in PPM
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
//Definitions
|
//Definitions
|
||||||
#define pin A0 //Analog input 0 of your arduino
|
#define pin A0 //Analog input 0 of your arduino
|
||||||
#define type 303 //MQ303
|
#define type 303 //MQ303
|
||||||
|
//#define calibration_button 13 //Pin to calibrate your sensor
|
||||||
|
|
||||||
//Declare Sensor
|
//Declare Sensor
|
||||||
MQUnifiedsensor MQ303(pin, type);
|
MQUnifiedsensor MQ303(pin, type);
|
||||||
@ -35,10 +36,19 @@ void setup() {
|
|||||||
Remarks: This function create the sensor object.
|
Remarks: This function create the sensor object.
|
||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
MQ303.inicializar();
|
MQ303.inicializar();
|
||||||
|
//pinMode(calibration_button, INPUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
MQ303.update();
|
MQ303.update();
|
||||||
|
/*
|
||||||
|
//Rutina de calibracion - Uncomment if you need (setup too and header)
|
||||||
|
if(calibration_button)
|
||||||
|
{
|
||||||
|
float R0 = MQ303.calibrate();
|
||||||
|
MQ303.setR0(R0):
|
||||||
|
}
|
||||||
|
*/
|
||||||
/***************************** MQReadSensor ****************************************
|
/***************************** MQReadSensor ****************************************
|
||||||
Input: Gas - Serial print flag
|
Input: Gas - Serial print flag
|
||||||
Output: Value in PPM
|
Output: Value in PPM
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
//Definitions
|
//Definitions
|
||||||
#define pin A0 //Analog input 0 of your arduino
|
#define pin A0 //Analog input 0 of your arduino
|
||||||
#define type 309 //MQ309
|
#define type 309 //MQ309
|
||||||
|
//#define calibration_button 13 //Pin to calibrate your sensor
|
||||||
|
|
||||||
//Declare Sensor
|
//Declare Sensor
|
||||||
MQUnifiedsensor MQ309(pin, type);
|
MQUnifiedsensor MQ309(pin, type);
|
||||||
@ -35,9 +36,19 @@ void setup() {
|
|||||||
Remarks: This function create the sensor object.
|
Remarks: This function create the sensor object.
|
||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
MQ309.inicializar();
|
MQ309.inicializar();
|
||||||
|
//pinMode(calibration_button, INPUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
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 ****************************************
|
/***************************** MQReadSensor ****************************************
|
||||||
Input: Gas - Serial print flag
|
Input: Gas - Serial print flag
|
||||||
Output: Value in PPM
|
Output: Value in PPM
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
//Definitions
|
//Definitions
|
||||||
#define pin A0 //Analog input 0 of your arduino
|
#define pin A0 //Analog input 0 of your arduino
|
||||||
#define type 4 //MQ4
|
#define type 4 //MQ4
|
||||||
|
//#define calibration_button 13 //Pin to calibrate your sensor
|
||||||
|
|
||||||
//Declare Sensor
|
//Declare Sensor
|
||||||
MQUnifiedsensor MQ4(pin, type);
|
MQUnifiedsensor MQ4(pin, type);
|
||||||
@ -35,10 +36,19 @@ void setup() {
|
|||||||
Remarks: This function create the sensor object.
|
Remarks: This function create the sensor object.
|
||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
MQ4.inicializar();
|
MQ4.inicializar();
|
||||||
|
//pinMode(calibration_button, INPUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
MQ4.update(); // Update data, the arduino will be read the voltaje in the analog pin
|
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 ****************************************
|
/***************************** MQReadSensor ****************************************
|
||||||
Input: Gas - Serial print flag
|
Input: Gas - Serial print flag
|
||||||
Output: Value in PPM
|
Output: Value in PPM
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
//Definitions
|
//Definitions
|
||||||
#define pin A0 //Analog input 0 of your arduino
|
#define pin A0 //Analog input 0 of your arduino
|
||||||
#define type 5 //MQ5
|
#define type 5 //MQ5
|
||||||
|
//#define calibration_button 13 //Pin to calibrate your sensor
|
||||||
|
|
||||||
//Declare Sensor
|
//Declare Sensor
|
||||||
MQUnifiedsensor MQ5(pin, type);
|
MQUnifiedsensor MQ5(pin, type);
|
||||||
@ -35,11 +36,20 @@ void setup() {
|
|||||||
Remarks: This function create the sensor object.
|
Remarks: This function create the sensor object.
|
||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
MQ5.inicializar();
|
MQ5.inicializar();
|
||||||
|
//pinMode(calibration_button, INPUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
|
|
||||||
MQ5.update(); // Update data, the arduino will be read the voltaje in the analog pin
|
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 ****************************************
|
/***************************** MQReadSensor ****************************************
|
||||||
Input: Gas - Serial print flag
|
Input: Gas - Serial print flag
|
||||||
Output: Value in PPM
|
Output: Value in PPM
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
//Definitions
|
//Definitions
|
||||||
#define pin A0 //Analog input 0 of your arduino
|
#define pin A0 //Analog input 0 of your arduino
|
||||||
#define type 6 //MQ6
|
#define type 6 //MQ6
|
||||||
|
//#define calibration_button 13 //Pin to calibrate your sensor
|
||||||
|
|
||||||
//Declare Sensor
|
//Declare Sensor
|
||||||
MQUnifiedsensor MQ6(pin, type);
|
MQUnifiedsensor MQ6(pin, type);
|
||||||
@ -35,10 +36,19 @@ void setup() {
|
|||||||
Remarks: This function create the sensor object.
|
Remarks: This function create the sensor object.
|
||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
MQ6.inicializar();
|
MQ6.inicializar();
|
||||||
|
//pinMode(calibration_button, INPUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
MQ6.update(); // Update data, the arduino will be read the voltaje in the analog pin
|
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 ****************************************
|
/***************************** MQReadSensor ****************************************
|
||||||
Input: Gas - Serial print flag
|
Input: Gas - Serial print flag
|
||||||
Output: Value in PPM
|
Output: Value in PPM
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
//Definitions
|
//Definitions
|
||||||
#define pin A0 //Analog input 0 of your arduino
|
#define pin A0 //Analog input 0 of your arduino
|
||||||
#define type 7 //MQ7
|
#define type 7 //MQ7
|
||||||
|
//#define calibration_button 13 //Pin to calibrate your sensor
|
||||||
|
|
||||||
|
|
||||||
//Declare Sensor
|
//Declare Sensor
|
||||||
@ -38,10 +39,19 @@ void setup() {
|
|||||||
Remarks: This function create the sensor object.
|
Remarks: This function create the sensor object.
|
||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
MQ7.inicializar();
|
MQ7.inicializar();
|
||||||
|
//pinMode(calibration_button, INPUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
MQ7.update(); // Update data, the arduino will be read the voltaje in the analog pin
|
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 ****************************************
|
/***************************** MQReadSensor ****************************************
|
||||||
Input: Gas - Serial print flag
|
Input: Gas - Serial print flag
|
||||||
Output: Value in PPM
|
Output: Value in PPM
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
//Definitions
|
//Definitions
|
||||||
#define pin A0 //Analog input 0 of your arduino
|
#define pin A0 //Analog input 0 of your arduino
|
||||||
#define type 8 //MQ8
|
#define type 8 //MQ8
|
||||||
|
//#define calibration_button 13 //Pin to calibrate your sensor
|
||||||
|
|
||||||
//Declare Sensor
|
//Declare Sensor
|
||||||
MQUnifiedsensor MQ8(pin, type);
|
MQUnifiedsensor MQ8(pin, type);
|
||||||
@ -35,10 +36,19 @@ void setup() {
|
|||||||
Remarks: This function create the sensor object.
|
Remarks: This function create the sensor object.
|
||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
MQ8.inicializar();
|
MQ8.inicializar();
|
||||||
|
//pinMode(calibration_button, INPUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
MQ8.update(); // Update data, the arduino will be read the voltaje in the analog pin
|
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 ****************************************
|
/***************************** MQReadSensor ****************************************
|
||||||
Input: Gas - Serial print flag
|
Input: Gas - Serial print flag
|
||||||
Output: Value in PPM
|
Output: Value in PPM
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
//Definitions
|
//Definitions
|
||||||
#define pin A0 //Analog input 0 of your arduino
|
#define pin A0 //Analog input 0 of your arduino
|
||||||
#define type 9 //MQ9
|
#define type 9 //MQ9
|
||||||
|
//#define calibration_button 13 //Pin to calibrate your sensor
|
||||||
|
|
||||||
//Declare Sensor
|
//Declare Sensor
|
||||||
MQUnifiedsensor MQ9(pin, type);
|
MQUnifiedsensor MQ9(pin, type);
|
||||||
@ -35,10 +36,19 @@ void setup() {
|
|||||||
Remarks: This function create the sensor object.
|
Remarks: This function create the sensor object.
|
||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
MQ9.inicializar();
|
MQ9.inicializar();
|
||||||
|
//pinMode(calibration_button, INPUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
MQ9.update(); // Update data, the arduino will be read the voltaje in the analog pin
|
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 ****************************************
|
/***************************** MQReadSensor ****************************************
|
||||||
Input: Gas - Serial print flag
|
Input: Gas - Serial print flag
|
||||||
Output: Value in PPM
|
Output: Value in PPM
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#define pin7 A7 //Analog input 7 of your arduino
|
#define pin7 A7 //Analog input 7 of your arduino
|
||||||
#define pin8 A8 //Analog input 8 of your arduino
|
#define pin8 A8 //Analog input 8 of your arduino
|
||||||
#define pin9 A9 //Analog input 9 of your arduino
|
#define pin9 A9 //Analog input 9 of your arduino
|
||||||
|
//#define calibration_button 13 //Pin to calibrate your sensor
|
||||||
|
|
||||||
//Declare Sensor
|
//Declare Sensor
|
||||||
MQUnifiedsensor MQ2(pin2, 2);
|
MQUnifiedsensor MQ2(pin2, 2);
|
||||||
@ -53,6 +54,7 @@ void setup() {
|
|||||||
MQ9.inicializar();
|
MQ9.inicializar();
|
||||||
//Print in serial monitor
|
//Print in serial monitor
|
||||||
Serial.print("MQ2 to MQ9 - lecture");
|
Serial.print("MQ2 to MQ9 - lecture");
|
||||||
|
//pinMode(calibration_button, INPUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
@ -65,7 +67,28 @@ void loop() {
|
|||||||
MQ7.update();
|
MQ7.update();
|
||||||
MQ8.update();
|
MQ8.update();
|
||||||
MQ9.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
|
//Read the sensor and print in serial port
|
||||||
LPG = MQ2.readSensor();
|
LPG = MQ2.readSensor();
|
||||||
Alcohol = MQ3.readSensor();
|
Alcohol = MQ3.readSensor();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user