Fixed example

This commit is contained in:
miguel5612
2020-03-26 11:54:18 -05:00
parent 1177d5827d
commit 3ae663163b
3 changed files with 26 additions and 64 deletions

View File

@ -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;
}

View File

@ -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;