MQ-2 Gas Sensor

Hi everyone ! ,
In my studies, I have a project where I use the MQ-2 gas sensor.
here is the program I use:

const int analogInPin = A0;  // Analog input pin that the potentiometer is attached to
const int ledPin = 13;                 // LED connected to digital pin 13

int sensorValue = 0; 


void setup() {
  // put your setup code here, to run once:
 Serial.begin(9600); 
  pinMode(ledPin, OUTPUT);      // sets the digital pin as output

}

void loop() {
  // put your main code here, to run repeatedly:
 sensorValue = analogRead(analogInPin);            
  // determine alarm status
  if (sensorValue >= 250)
  {
    digitalWrite(ledPin, HIGH);   // sets the LED on
  }
  else
  {
  digitalWrite(ledPin, LOW);    // sets the LED off
  }

  // print the results to the serial monitor:
  Serial.print("sensor = " );                       
  Serial.println(sensorValue);     
  delay(750);                     
}

the program is to light a LED when the gas rate is greater than 250ppm.

But I have a problem;
that there is an equation for an analog value to a value ppm?

Then datasheet says that this sensor can capture several gas but I have only one value,
Can we have several value display simultaneously?

If someone has an MQ-2 program that works, I'm interested

thank you in advance :slight_smile:

Jeremy

Hi, welcome to the forum.

This is some basic information : Arduino Playground - MQGasSensors

Bonjour j'ai le même problème que toi pour un de mes collègues il le résout et je te le passe

jean lc

Hello,

See discussion here for calibration in open air:

Here are my libraries with curves calculated from datasheets :

The MQ series are very cheap, variable, and change their values in time. It is a good entry point but no more after. Oftern the knob on the pre-assemble boards are only sed for the digital signal and its led on the board.

For H2, I am now considering MIcS sensors.

Hello,
Thank you for your reply !

I looked your libraries with curves calculated from datasheets :

But I have the MQ2 gas sensor only; Have you got functional program epierre ?

Jeremy