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

Confused because coding/annotations do not match #2

Open
schlaubstar opened this issue Apr 23, 2017 · 1 comment
Open

Confused because coding/annotations do not match #2

schlaubstar opened this issue Apr 23, 2017 · 1 comment

Comments

@schlaubstar
Copy link

Hi ... at first a great thank you for your work but I'm confused with your code.

You always say for your function:
/****************** MQResistanceCalculation **************************************** Input: raw_adc - raw value read from adc, which represents the voltage....

but when it gets called e.g. by MQCalibration you only pass the value of analogRead(mq_pin) as raw_adc like here ..

float MQCalibration(int mq_pin) { ..... for (i=0;i<CALIBARAION_SAMPLE_TIMES;i++) { //take multiple samples RS_AIR_val += MQResistanceCalculation(analogRead(mq_pin)); ..... }

For my understanding analogRead will return a value between 0 an 1023 indicating "units" of voltage.
To convert those to the voltage representation you would actually have to do something like multiplying it with the voltage of your device - in most cases when using MQ-x Sensors, youll go with a 5V arduino so it should be:

MQResistanceCalculation(analogRead(mq_pin) * 5.0 / 1023.0);

or am I wrong ?

@mdsiraj1992
Copy link
Owner

mdsiraj1992 commented May 1, 2017

"MQResistanceCalculation(analogRead(mq_pin) * 5.0 / 1023.0);"

This exact same thing is being done by the MQResistanceCalculation function used in the code in a different way
`float MQResistanceCalculation(int raw_adc)
{
return ( ((float)RL_VALUE_MQ135*(1023-raw_adc)/raw_adc));
}

Watch this video(https://www.youtube.com/watch?v=bL0cySlLlYo&index=1&list=PLwc7ohfhglpty1sZS0iTDxsNQ-CIaeR1X) maybe you will understand it (don't worry about the language in the video, even i don;t know it)
`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants