mirror of
https://github.com/miguel5612/MQSensorsLib.git
synced 2025-03-15 05:17:30 +03:00
Fixed ADC_Bit_Resolution for _ADC_Bit_Resolution
This commit is contained in:
parent
f8d1bcbc76
commit
ff0cb0562a
@ -27,7 +27,7 @@ void MQUnifiedsensor::setRL(float RL) {
|
|||||||
}
|
}
|
||||||
void MQUnifiedsensor::setADC(int value)
|
void MQUnifiedsensor::setADC(int value)
|
||||||
{
|
{
|
||||||
this-> _sensor_volt = (value) * _VOLT_RESOLUTION / (pow(2, ADC_RESOLUTION) - 1);
|
this-> _sensor_volt = (value) * _VOLT_RESOLUTION / (pow(2, _ADC_Bit_Resolution) - 1);
|
||||||
this-> _adc = value;
|
this-> _adc = value;
|
||||||
}
|
}
|
||||||
void MQUnifiedsensor::setVoltResolution(float voltage_resolution)
|
void MQUnifiedsensor::setVoltResolution(float voltage_resolution)
|
||||||
@ -95,7 +95,7 @@ void MQUnifiedsensor::serialDebug(bool onSetup)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Serial.print("|"); Serial.print(_adc); Serial.print("| v = ADC*"); Serial.print(_VOLT_RESOLUTION); Serial.print("/"); Serial.print(pow(2, _ADC_Bit_Resolution)); 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(" | RS = ((" ); Serial.print(_VOLT_RESOLUTION ); Serial.print("*RL)/Voltage) - RL| "); Serial.print(_RS_Calc); Serial.print(" | Ratio = RS/R0| ");
|
||||||
Serial.print(_ratio); Serial.print( " | ");
|
Serial.print(_ratio); Serial.print( " | ");
|
||||||
if(_regressionMethod == 1) Serial.print("ratio*a + b");
|
if(_regressionMethod == 1) Serial.print("ratio*a + b");
|
||||||
@ -174,7 +174,7 @@ float MQUnifiedsensor::getVoltage(int read) {
|
|||||||
avg += _adc;
|
avg += _adc;
|
||||||
delay(retry_interval);
|
delay(retry_interval);
|
||||||
}
|
}
|
||||||
voltage = (avg/ retries) * _VOLT_RESOLUTION / (pow(2, ADC_RESOLUTION) - 1);
|
voltage = (avg/ retries) * _VOLT_RESOLUTION / (pow(2, _ADC_Bit_Resolution) - 1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user