Introduction
MQ2 Gas Sensor module is used for detecting the leakage of harmful gas, such a combustible gas, also detect smoke. The material of gas sensor is SnO2. There’s a potentiometer used for adjusting the sensitivity, the concept of this sensor module is: conductivity rate become higher and higher with the growth of concentration, therefore, when detect harmful gas, it outputs low power.
There are two types output way: digital output and analog output, it’s convenient to get digital data and analog data.
Datasheet
Input voltage: DC 5V
Current: 150mA
Digital Output: TTL 0 is 0.1V and TTL 1 is 5V
Analog Output: 0.1 to 0.3V (it seems that there’s almost no pollution), when harmful gas’ concentration reach max, analog output will become 4V
Tip: MQ2 sensor module needs about 20s to preheat, measuring data will be stable in this way, by the way, sensor module will heat, that’s normal, because there’s a heating wire in it, however, if it’s getting too hot, it must have problem in your circuit.
Symbol Detect Gas Detect Concentration
MQ-2 combustible gas 300-10000ppm
Smoke, hydrogen
propane
MQ-5 LPG, natural gas 300-10000ppm
Town gas
MQ-135 Carbon oxide, coal gas 300-10000ppm
Features
DO: TTL output
AO: Analog output, it will be higher with more such gas.
Preheat time: Over 20s
Being sensitive in detecting gas, town gas and smoking
Analog output voltage getting higher and higher with the gas’ concentration
TTL output low power is effective signal, when detect the harmful gas, it output low power, then indicate led light.
Usage
[code]
int smokeAO=A5; //Define the A5 pin as smokeAO.
int ledRed=11; //Define the 11 pin as ledRed.
int threshold=350; //Your threshold value.
void setup()
{
pinMode(ledRed, OUTPUT);
pinMode(smokeAO, INPUT);
Serial.begin(9600);
delay(20000);
}
void loop()
{
int analogSensor=digitalRead(smokeAO);
Serial.print("analogoutput: ");
Serial.println(analogSensor);
if(analogSensor > threshold)
{
digitalWrite(ledRed, HIGH); //when the output of sensor is exceed to threshold, the led on.
}
else
{
digitalWrite(ledRed, LOW);
}
delay(300);
}
[/code]
Resource