diff --git a/src/MQUnifiedsensor.cpp b/src/MQUnifiedsensor.cpp index 6357d91..bc94ed0 100644 --- a/src/MQUnifiedsensor.cpp +++ b/src/MQUnifiedsensor.cpp @@ -107,8 +107,8 @@ int MQUnifiedsensor::readSensor(String nameLectureRequeired, bool print) String nameLecture = getnameLecture(); Serial.println("**********************"); Serial.println("* Sensor: MQ-" + String(_type)); - Serial.println("* m =" + String(_m) + " ,b =" + String(_b)); - Serial.println("* RS/R0 = " + String(_ratio) + " ,Voltaje leido(ADC): " + String(this->getVoltage())); + Serial.println("* m =" + String(_m) + " ,b =" + String(_b) + ", R0 = " + _R0); + Serial.println("* RS/R0 = " + String(_ratio) + " ,Voltaje leido(ADC): " + String(_sensor_volt)); Serial.println("* Lectura(" + nameLecture + ")=" + String(_PPM) + " PPM"); Serial.println("**********************"); } @@ -148,10 +148,10 @@ int MQUnifiedsensor::readPPM(int m, int b) { /** * Returns the PPM concentration */ - double sensor_volt = this->getVoltage(); + _sensor_volt = this->getVoltage(); double RS_gas; //Define variable for sensor resistance - RS_gas = ((VOLT_RESOLUTION*RLValue)/sensor_volt)-RLValue; //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 @@ -172,12 +172,12 @@ int MQUnifiedsensor::calibrate() { RS = [(VC x RL) - (VRL x RL)] / VRL RS = [(VC x RL) / VRL] - RL */ - float sensor_volt; //Define variable for sensor voltage + _sensor_volt; //Define variable for sensor voltage float RS_air; //Define variable for sensor resistance float R0; //Define variable for R0 float sensorValue; //Define variable for analog readings - sensor_volt = this->getVoltage(); //Convert average to voltage - RS_air = ((VOLT_RESOLUTION*RLValue)/sensor_volt)-RLValue; //Calculate RS in fresh air + _sensor_volt = this->getVoltage(); //Convert average to voltage + RS_air = ((VOLT_RESOLUTION*RLValue)/_sensor_volt)-RLValue; //Calculate RS in fresh air R0 = RS_air/_ratioInCleanAir; //Calculate R0 return R0; } diff --git a/src/MQUnifiedsensor.h b/src/MQUnifiedsensor.h index 2b6f853..e159386 100644 --- a/src/MQUnifiedsensor.h +++ b/src/MQUnifiedsensor.h @@ -11,7 +11,7 @@ /************************Global vars************************************/ int VOLT_RESOLUTION = 5.0; // if 3.3v use 3.3 int RLValue = 10; //Value in KiloOhms -int _ratioInCleanAir, _PPM; +int _ratioInCleanAir, _PPM, _sensor_volt; double RS_air, _m, _b, _ratio; /************************Hardware Related Macros************************************/