mirror of
https://github.com/miguel5612/MQSensorsLib.git
synced 2025-07-25 21:51:04 +03:00
Fixed example
This commit is contained in:
@ -99,7 +99,7 @@ float MQUnifiedsensor::readSensor()
|
||||
//if(_PPM > 10000) _PPM = 99999999; //No negative values accepted or upper datasheet recomendation.
|
||||
return _PPM;
|
||||
}
|
||||
float MQUnifiedsensor::calibrate() {
|
||||
float MQUnifiedsensor::calibrate(float ratioInCleanAir) {
|
||||
//More explained in: https://jayconsystems.com/blog/understanding-a-gas-sensor
|
||||
/*
|
||||
V = I x R
|
||||
@ -116,7 +116,7 @@ float MQUnifiedsensor::calibrate() {
|
||||
float R0; //Define variable for R0
|
||||
RS_air = ((_VOLT_RESOLUTION*_RL)/_sensor_volt)-_RL; //Calculate RS in fresh air
|
||||
if(RS_air < 0) RS_air = 0; //No negative values accepted.
|
||||
R0 = RS_air/_ratioInCleanAir; //Calculate R0
|
||||
R0 = RS_air/ratioInCleanAir; //Calculate R0
|
||||
if(R0 < 0) R0 = 0; //No negative values accepted.
|
||||
return R0;
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ class MQUnifiedsensor
|
||||
void serialDebug(bool onSetup = false); //Show on serial port information about sensor
|
||||
|
||||
//user functions
|
||||
float calibrate();
|
||||
float calibrate(float ratioInCleanAir);
|
||||
float readSensor();
|
||||
|
||||
//get function for info
|
||||
@ -42,7 +42,6 @@ class MQUnifiedsensor
|
||||
byte _pin;
|
||||
byte _firstFlag = false;
|
||||
byte _VOLT_RESOLUTION = 5.0; // if 3.3v use 3.3
|
||||
byte _ratioInCleanAir;
|
||||
byte _RL = 10; //Value in KiloOhms
|
||||
byte _ADC_Bit_Resolution = 10;
|
||||
|
||||
|
Reference in New Issue
Block a user