How can I convert AnalogRead to something useful?

In the equation

Rs/RL=Vc/(Vrl-1).

the value that you are measuring is a function of Vrl: Vrl = sensorValue * 5.0 / 1024.0. Vc is 5.0 volts, if you are connecting the sensor to a regulated power source on the Arduino. Rl is, according to the schematic, 10K.

Now, how that will help you, I don't know. The charts are all log charts, so any ppm reading will involve the log function.

i see.. i try to use the code which is posted by thermike. well i dont know exactly if its correct because i also have difficulty in interpreting the datasheet. what ive done is. every 1.4V cycle i get the value of CO and then display in LCD.im really confused

Has anyone figured this out yet? I have an MQ-2 sensor with a potentiometer attached. I have no idea how to actually detect a proper methane reading.

http://www.ebay.com.au/itm/Arduino-Shield-Smoke-Gas-Sensor-Module-MQ2-free-Cable-/280615774635?pt=LH_DefaultDomain_0&hash=item415600e9ab

Don't know if it's of any help to you, but at the refinery I worked at they had hundreds of gas detectors, mostly for safety alarming purposes. CO2, H2S, O2, etc. These were pretty expensive industrial instruments, but the typical calibration procedure was using ambient air for the 'zero' value, and purchased 'calibration gas' bottle/regulators for setting the upper end value of the scale. That is, there was no way to calibrate just using internal voltage values, or constant values, etc, as these kinds of sensors have a finite life and age over time, so accuracy is only as good as the calibration gas you use and how frequently you performed it. We did monthly or quartily depending on the gas type and area safety ratings. The calibration gas bottles were pretty expensive also, plus they had a specified shelf life that when passed their accuracy became 'invalid' and we would have to send them back for refilling even if not empty.

Okay, now the MQ-2 seems to be working fine using the following code:

int sensorValue;

void setup()
{
  Serial.begin(9600);      // sets the serial port to 9600
}

void loop() 
{
  sensorValue = analogRead(0);       // read analog input pin 0
  Serial.println(sensorValue, DEC);
  
  if (sensorValue >= 5) {
    Serial.println("Someone let one rip!");
    delay(10000);
  }
}

so i guess the sensorValue there is in analog value.correct me if im wrong.. thank you.!

vhenamae:
so i guess the sensorValue there is in analog value.correct me if im wrong.. thank you.!

Yes, It is!

 sensorValue = analogRead(0);       // read analog input pin 0

cyclegadget:

vhenamae:
so i guess the sensorValue there is in analog value.correct me if im wrong.. thank you.!

Yes, It is!

 sensorValue = analogRead(0);       // read analog input pin 0

so.. how can i convert that analogvalue to digital? thank you

What do you mean by convert it to digital?

i mean converting it to ppm values..

I don't know. I imagine the datasheet for your sensor will have that information.

i see.. thank you sir. i already have a code. but still im not that confident about the about.

vhenamae:
i see.. thank you sir. i already have a code. but still im not that confident about the about.

Why do you want to convert to PPM?

What sensor are you using?

im using MQ-7 sir.. and im very confused with its datasheet..

im using MQ-7 sir

A link would be far more useful.

Why are you using this thing? What is it that you expect this thing to tell you? Before you can convert the value returned by analogRead to something useful, it is necessary to know what the sensor is measuring, what the output of the sensor is, whether the output is linear or logarithmic, and what you want to do with the output.

You seem to have omitted a few of these details and not enabled us to find any of them.

I assume it's this: Carbon Monoxide Sensor - MQ-7 - SEN-09403 - SparkFun Electronics

Since the datasheet expresses the PPM value as a ratio of the resistance of the device of the device in clean air with 100PPM carbon monoxide, it suggests that the PPM value isn't accurately available without calibration with a sample gas of the correct constituants. Which is what Retrolefty said several posts back. There is a value given for clean air which is much easier to obtain but with a much lesser degree of accuracy. It still needs you to calibrate the thing though. If accuracy isn't too much of an issue, the first step would be to wire the thing up and see what its resistance is when its been running a while in clean air. Then when you have this figure you work out a nice value for a static resistor for the other side of the voltage divider for the anticipated ranges you want it to measure. I'd use a lookup table to get a figure out what the PPM is.

A completely unsuitable device to be selling to home users in other words....

wildbill:
I assume it's this: Carbon Monoxide Sensor - MQ-7 - SEN-09403 - SparkFun Electronics

yes sir.. im using that one.

hi all,

how should I do the preheating? does it need to be 24+ hours continously, or can I do it in 2 or 3 passes (so 2x12 or 3x8 hours)?