@ -143,6 +143,24 @@ float MQUnifiedsensor::readSensor()
//if(_PPM > 10000) _PPM = 99999999; //No negative values accepted or upper datasheet recomendation.
return _PPM ;
}
float MQUnifiedsensor : : readSensorR0Rs ( )
{
//More explained in: https://jayconsystems.com/blog/understanding-a-gas-sensor
_RS_Calc = ( ( _VOLT_RESOLUTION * _RL ) / _sensor_volt ) - _RL ; //Get value of RS in a gas
if ( _RS_Calc < 0 ) _RS_Calc = 0 ; //No negative values accepted.
_ratio = this - > _R0 / _RS_Calc ; // Get ratio RS_air/RS_gas <- INVERTED for MQ-131 issue 28 https://github.com/miguel5612/MQSensorsLib/issues/28
if ( _ratio < = 0 ) _ratio = 0 ; //No negative values accepted or upper datasheet recomendation.
if ( _regressionMethod = = 1 ) _PPM = _a * pow ( _ratio , _b ) ; // <- Source excel analisis https://github.com/miguel5612/MQSensorsLib_Docs/tree/master/Internal_design_documents
else
{
// https://jayconsystems.com/blog/understanding-a-gas-sensor <- Source of linear ecuation
double ppm_log = ( log10 ( _ratio ) - _b ) / _a ; //Get ppm value in linear scale according to the the ratio value
_PPM = pow ( 10 , ppm_log ) ; //Convert ppm value to log scale
}
if ( _PPM < 0 ) _PPM = 0 ; //No negative values accepted or upper datasheet recomendation.
//if(_PPM > 10000) _PPM = 99999999; //No negative values accepted or upper datasheet recomendation.
return _PPM ;
}
float MQUnifiedsensor : : calibrate ( float ratioInCleanAir ) {
//More explained in: https://jayconsystems.com/blog/understanding-a-gas-sensor
/*