You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 ..
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:
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));
}
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 ?
The text was updated successfully, but these errors were encountered: