My query:
The default position of the resistor pot a it shows different RO values at different resistor settings but the answer is around the same range
For better accuracy, What is the default position?
There is no recommended settings for Resistor POT. It depends on the sensitivity range required for your application. Please refer to MQ-2 datasheet for few pointers to set the Load Resistor value (i.e POT).
If you are unsure, keeping the POT resistance at mid point would be sufficient for most applications.
I made use of the foll codes for using with Arduino UNO
[code]const int analogInPin = A2; // Analog input pin that the potentiometer is attached to
int outputValue;
void setup()
{
// initialize serial communications at 9600 bps:
Serial.begin(9600);
}
void loop()
{
// read the analog in value:
int sensorValue = analogRead(analogInPin);
outputValue = map(sensorValue, 0, 1023, 0, 100); //Gives the analog value in % //Serial.println(sensorValue);
Serial.println(outputValue);
delay(1000);
}[/code]
Your code does not make use of the calculation that are already provided. If you are just looking for detection (i.e sense presense of a particular gas at a threshold), it might be useful.
In your code, you are reading the analog value and mapping it to 0 - 100 range. Please understand that this sensor’s voltage range is non-linear. It also depends on the load resistor value (POT).
It is better to use the analog value range 0 - 1023 to set gas detection threshold. If you intened to measure the concentration, follow the direction given in the Wiki.
The Rs/R0 seems to be correct. BTW, the wiki only provides a method for approximate measurement. The measured value needs to be matched with the graph.
"According to the graph, we can see that the minimum concentration we can test is 100ppm and the maximum is 10000ppm, in a other word, we can get a concentration of gas between 0.01% and 1%. However, we can’t provide a formula because the relation between ratio and concentration is nonlinear. "
Hence, these sensors are suitable for detection & not measurement. Measurement requires using professional equipments to calibarate the sensor. The read value must be matched against professional equipment value.
As mentioned earlier, these sensors are only suitable for detection not for measurement. You would need to use reference measurement using professional gas measurement tool to correlate.