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
|
||||
#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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user