mirror of
https://github.com/miguel5612/MQSensorsLib.git
synced 2025-07-02 02:11:04 +03:00
Updated examples
This commit is contained in:
@ -17,19 +17,39 @@
|
||||
#include <MQUnifiedsensor.h>
|
||||
|
||||
//Definitions
|
||||
#define placa "Arduino UNO"
|
||||
#define Voltage_Resolution 5
|
||||
#define pin A0 //Analog input 0 of your arduino
|
||||
#define type 2 //MQ2
|
||||
#define type "MQ-2" //MQ2
|
||||
#define ADC_Bit_Resolution 10 // For arduino UNO/MEGA/NANO
|
||||
|
||||
|
||||
//Defaults, uncomment if you need
|
||||
#define RatioMQ2CleanAir 9.83 //RS / R0 = 9.83 ppm
|
||||
//#define RatioMQ3CleanAir 60 //RS / R0 = 60 ppm
|
||||
//#define RatioMQ4CleanAir 4.4 //RS / R0 = 4.4 ppm
|
||||
//#define RatioMQ5CleanAir 6.5 //RS / R0 = 6.5 ppm
|
||||
//#define RatioMQ6CleanAir 10 //RS / R0 = 10 ppm
|
||||
//#define RatioMQ7CleanAir 27.5 //RS / R0 = 27.5 ppm
|
||||
//#define RatioMQ8CleanAir 70 //RS / R0 = 70 ppm
|
||||
//#define RatioMQ9CleanAir 9.6 //RS / R0 = 9.6 ppm
|
||||
//#define RatioMQ131CleanAir 15 //RS / R0 = 15 ppm
|
||||
//#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(pin, type);
|
||||
MQUnifiedsensor MQ2(placa, Voltage_Resolution, ADC_Bit_Resolution, pin2, type);
|
||||
unsigned long contador = 0;
|
||||
|
||||
void setup() {
|
||||
//Init serial port
|
||||
Serial.begin(115200);
|
||||
MQ2.setRegressionMethod("Exponential"); //_PPM = a*ratio^b
|
||||
MQ2.setA(574.25); MQ2.setB(-2.222); // Configurate the ecuation values to get LPG concentration
|
||||
//init the sensor
|
||||
MQ2.inicializar();
|
||||
MQ2.init();
|
||||
//Print in serial monitor
|
||||
Serial.print("MQ2 - Calibracion");
|
||||
Serial.print("Note - Make sure you are in a clean room and the sensor has pre-heated almost 4 hours");
|
||||
@ -38,7 +58,7 @@ void setup() {
|
||||
|
||||
void loop() {
|
||||
//Read the sensor and print in serial port
|
||||
int lecture = MQ2.calibrate();
|
||||
int lecture = MQ2.calibrate(RatioMQ2CleanAir);
|
||||
//Print in serial monitor
|
||||
Serial.print(String(contador) + ",");
|
||||
Serial.println(lecture);
|
||||
|
Reference in New Issue
Block a user