Added print serial

This commit is contained in:
miguel5612 2019-05-29 22:17:25 -05:00
parent d6530691aa
commit 2408b9f0bb
2 changed files with 9 additions and 2 deletions

View File

@ -157,7 +157,7 @@ int MQUnifiedsensor::readPPM(int m, int b) {
double ppm = pow(10, ppm_log); //Convert ppm value to log scale
return floor(ppm);
}
int MQUnifiedsensor::calibrate() {
int MQUnifiedsensor::calibrate(boolean print) {
//More explained in: https://jayconsystems.com/blog/understanding-a-gas-sensor
/*
V = I x R
@ -177,6 +177,13 @@ int MQUnifiedsensor::calibrate() {
_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
if(print)
{
Serial.println("_sensor_volt: " + String(_sensor_volt));
Serial.println("_VOLT_RESOLUTION: " + String(_VOLT_RESOLUTION));
Serial.println("_ratioInCleanAir: " + String(_ratioInCleanAir));
Serial.println("R0: " + String(R0));
}
return R0;
}
double MQUnifiedsensor::getVoltage() {

View File

@ -86,7 +86,7 @@ class MQUnifiedsensor
int readSensor(String nameLectureRequeired = "", bool print = false);
int readPPM(int m, int b);
int calibrate();
int calibrate(boolean print = false);
double getVoltage();
double stringToDouble(String & str);