mirror of
https://github.com/miguel5612/MQSensorsLib.git
synced 2025-03-25 10:10:01 +03:00
Created defautls
This commit is contained in:
parent
37db4af4bf
commit
33c9ae2c7c
@ -139,7 +139,7 @@ int MQUnifiedsensor::readPPM(int m, int b) {
|
|||||||
double sensor_volt = this->getVoltage();
|
double sensor_volt = this->getVoltage();
|
||||||
double RS_gas; //Define variable for sensor resistance
|
double RS_gas; //Define variable for sensor resistance
|
||||||
|
|
||||||
RS_gas = ((5.0 * 10.0) / sensor_volt) - 10.0; //Get value of RS in a gas
|
RS_gas = ((VOLT_RESOLUTION*RLValue)/sensor_volt)-RLValue; //Get value of RS in a gas
|
||||||
|
|
||||||
_ratio = RS_gas / this->_R0; // Get ratio RS_gas/RS_air
|
_ratio = RS_gas / this->_R0; // Get ratio RS_gas/RS_air
|
||||||
|
|
||||||
@ -147,7 +147,7 @@ int MQUnifiedsensor::readPPM(int m, int b) {
|
|||||||
double ppm = pow(10, ppm_log); //Convert ppm value to log scale
|
double ppm = pow(10, ppm_log); //Convert ppm value to log scale
|
||||||
return floor(ppm);
|
return floor(ppm);
|
||||||
}
|
}
|
||||||
double MQUnifiedsensor::calibrate() {
|
int MQUnifiedsensor::calibrate() {
|
||||||
//More explained in: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
//More explained in: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
||||||
/*
|
/*
|
||||||
V = I x R
|
V = I x R
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
int VOLT_RESOLUTION = 5.0; // if 3.3v use 3.3
|
int VOLT_RESOLUTION = 5.0; // if 3.3v use 3.3
|
||||||
int RLValue = 10; //Value in KiloOhms
|
int RLValue = 10; //Value in KiloOhms
|
||||||
int _ratioInCleanAir, _PPM;
|
int _ratioInCleanAir, _PPM;
|
||||||
double RS_air,_R0, _m, _b, _ratio;
|
double RS_air, _m, _b, _ratio;
|
||||||
|
|
||||||
/************************Hardware Related Macros************************************/
|
/************************Hardware Related Macros************************************/
|
||||||
|
|
||||||
@ -45,6 +45,20 @@ double RS_air,_R0, _m, _b, _ratio;
|
|||||||
#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
|
||||||
|
|
||||||
|
//From the calibration program we can obtain the R0 value for each sensor
|
||||||
|
#define R0_MQ2 1 //R0 after 48 hours pre-heating the sensor
|
||||||
|
#define R0_MQ3 1 //R0 after 48 hours pre-heating the sensor
|
||||||
|
#define R0_MQ4 1 //R0 after 48 hours pre-heating the sensor
|
||||||
|
#define R0_MQ5 1 //R0 after 48 hours pre-heating the sensor
|
||||||
|
#define R0_MQ6 1 //R0 after 48 hours pre-heating the sensor
|
||||||
|
#define R0_MQ7 1 //R0 after 48 hours pre-heating the sensor
|
||||||
|
#define R0_MQ8 1 //R0 after 48 hours pre-heating the sensor
|
||||||
|
#define R0_MQ9 1 //R0 after 48 hours pre-heating the sensor
|
||||||
|
#define R0_MQ131 1 //R0 after 48 hours pre-heating the sensor
|
||||||
|
#define R0_MQ135 1//R0 after 48 hours pre-heating the sensor
|
||||||
|
#define R0_MQ303 1 //R0 after 48 hours pre-heating the sensor
|
||||||
|
#define R0_MQ309 1 //R0 after 48 hours pre-heating the sensor
|
||||||
|
|
||||||
/***********************Software Related Macros************************************/
|
/***********************Software Related Macros************************************/
|
||||||
|
|
||||||
#define ADC_RESOLUTION 10 // for 10bit analog to digital converter.
|
#define ADC_RESOLUTION 10 // for 10bit analog to digital converter.
|
||||||
@ -80,7 +94,7 @@ class MQUnifiedsensor
|
|||||||
int readSensor(String nameLectureRequeired = "", bool print = false);
|
int readSensor(String nameLectureRequeired = "", bool print = false);
|
||||||
int readPPM(int m, int b);
|
int readPPM(int m, int b);
|
||||||
|
|
||||||
double calibrate();
|
int calibrate();
|
||||||
double getVoltage();
|
double getVoltage();
|
||||||
double stringToDouble(String & str);
|
double stringToDouble(String & str);
|
||||||
|
|
||||||
@ -89,7 +103,7 @@ class MQUnifiedsensor
|
|||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int _pin, _type;
|
int _pin, _type, _R0;
|
||||||
String _MQ[19], _nameLectureRequeired;
|
String _MQ[19], _nameLectureRequeired;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user