Skip to content

Commit

Permalink
Added parenthesis to make clear the operation
Browse files Browse the repository at this point in the history
  • Loading branch information
miguel5612 committed Apr 4, 2020
1 parent edd573b commit 39b4449
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/MQUnifiedsensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void MQUnifiedsensor::setRL(float RL) {
}
void MQUnifiedsensor::setADC(int value)
{
this-> _sensor_volt = (value) * _VOLT_RESOLUTION / (pow(2, _ADC_Bit_Resolution) - 1);
this-> _sensor_volt = (value) * _VOLT_RESOLUTION / ((pow(2, _ADC_Bit_Resolution)) - 1);
this-> _adc = value;
}
void MQUnifiedsensor::setVoltResolution(float voltage_resolution)
Expand Down Expand Up @@ -95,7 +95,7 @@ void MQUnifiedsensor::serialDebug(bool onSetup)
}
else
{
Serial.print("|"); Serial.print(_adc); Serial.print("| v = ADC*"); Serial.print(_VOLT_RESOLUTION); Serial.print("/"); Serial.print(pow(2, _ADC_Bit_Resolution) - 1); Serial.print(" | "); Serial.print(_sensor_volt);
Serial.print("|"); Serial.print(_adc); Serial.print("| v = ADC*"); Serial.print(_VOLT_RESOLUTION); Serial.print("/"); Serial.print((pow(2, _ADC_Bit_Resolution)) - 1); Serial.print(" | "); Serial.print(_sensor_volt);
Serial.print(" | RS = ((" ); Serial.print(_VOLT_RESOLUTION ); Serial.print("*RL)/Voltage) - RL| "); Serial.print(_RS_Calc); Serial.print(" | Ratio = RS/R0| ");
Serial.print(_ratio); Serial.print( " | ");
if(_regressionMethod == 1) Serial.print("ratio*a + b");
Expand Down Expand Up @@ -174,7 +174,7 @@ float MQUnifiedsensor::getVoltage(int read) {
avg += _adc;
delay(retry_interval);
}
voltage = (avg/ retries) * _VOLT_RESOLUTION / (pow(2, _ADC_Bit_Resolution) - 1);
voltage = (avg/ retries) * _VOLT_RESOLUTION / ((pow(2, _ADC_Bit_Resolution)) - 1);
}
else
{
Expand Down

0 comments on commit 39b4449

Please sign in to comment.