Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

possible error in the calculation formula for _RS_Calc = ((_VOLT_RESOLUTION*_RL)/_sensor_volt)-_RL; #74

Open
berryPiTech opened this issue Mar 13, 2024 · 2 comments
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@berryPiTech
Copy link

I think there is an error in the library source code (https://github.com/miguel5612/MQSensorsLib/blob/master/src/MQUnifiedsensor.cpp):

The variable _VOLT_RESOLUTION in the equation below should be 5V, not _VOLT_RESOLUTION, which is 3.3volts in case of esp32.
_RS_Calc = ((_VOLT_RESOLUTION*_RL)/_sensor_volt)-_RL; //Get value of RS in a gas

The above equation (line 148) is supposed to be the implementation of this equation in this link (https://www.jaycon.com/understanding-a-gas-sensor/).

RS = [(VC x RL) / VRL] – RL

The variables are in figure 6 of the link above.

Specifically Vcc=5V is the vcc to drive the heater of the sensor. It can't be 3.3volts, which is too low to drive the heater.

The correct formula should be:
_RS_Calc = ((_VCC*_RL)/_sensor_volt)-_RL;

where VCC = 5volts.

@daguerpedro
Copy link

You're right!
Also, i guess the method 'calibrate' is also incorrect, do you agree?

It should calculate a R0.
R0 is RS in fresh air, according to the sensor manufacturer.

But this method is getting RS in fresh air and dividing by a predefined RS in clean air. In others words, this method gets a RS/R0 instead of R0.

The point of calibration R0 is to get a RS in fresh air.

Do you agree?

@miguel5612
Copy link
Owner

@berryPiTech Thank you for raising these important points about the formula and the calibration method. To address this issue and improve the library, we would appreciate a pull request that introduces a new method to calculate RS using the correct formula
Additionally, it would be helpful if this pull request could include examples demonstrating how to use this method, especially with different sensors and scenarios, such as using a 5V VCC for proper sensor operation. This will ensure users can apply the formula correctly based on their specific setups.
We encourage you to contribute the necessary changes, and your input will be highly valued by the community!

@miguel5612 miguel5612 added enhancement New feature or request help wanted Extra attention is needed good first issue Good for newcomers labels Sep 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants