Compare commits

..

4 Commits

Author SHA1 Message Date
Miguel Angel Califa Urquiza
748ff3055c Merge branch 'master' into codex/modificar-cálculo-usando-voltres-en-readsensor 2025-06-04 17:49:48 -05:00
Miguel Angel Califa Urquiza
a6abda567f Merge pull request #80 from miguel5612/codex/detectar-y-corregir-error-en-código-base
Fix MQ303A voltage offset
2025-06-04 17:47:23 -05:00
Miguel Angel Califa Urquiza
92f3c30e82 Fix MQ303A voltage offset bug 2025-06-04 17:46:28 -05:00
Miguel Angel Califa Urquiza
da3adb7335 fix: preserve voltage resolution 2025-06-04 17:46:18 -05:00

View File

@@ -142,10 +142,13 @@ float MQUnifiedsensor::validateEcuation(float ratioInput)
float MQUnifiedsensor::readSensor(bool isMQ303A, float correctionFactor, bool injected) float MQUnifiedsensor::readSensor(bool isMQ303A, float correctionFactor, bool injected)
{ {
//More explained in: https://jayconsystems.com/blog/understanding-a-gas-sensor //More explained in: https://jayconsystems.com/blog/understanding-a-gas-sensor
float voltRes = _VOLT_RESOLUTION; // preserve global resolution
if(isMQ303A) { if(isMQ303A) {
_VOLT_RESOLUTION = _VOLT_RESOLUTION - 0.45; //Calculations for RS using mq303a sensor look wrong #42 voltRes = voltRes - 0.45; //Calculations for RS using mq303a sensor look wrong #42
} }
_RS_Calc = ((_VOLT_RESOLUTION*_RL)/_sensor_volt)-_RL; //Get value of RS in a gas _RS_Calc = ((voltRes*_RL)/_sensor_volt)-_RL; //Get value of RS in a gas
if(_RS_Calc < 0) _RS_Calc = 0; //No negative values accepted. if(_RS_Calc < 0) _RS_Calc = 0; //No negative values accepted.
if(!injected) _ratio = _RS_Calc / this->_R0; // Get ratio RS_gas/RS_air if(!injected) _ratio = _RS_Calc / this->_R0; // Get ratio RS_gas/RS_air
_ratio += correctionFactor; _ratio += correctionFactor;