Mq2 gas sensor is not working

Hello there
I have made a project using MQ2 gas sensor.
I have tested it with a lighter but it is not detecting anything
It only returns with the value 1023 in serial monitor
Can you please help what I am doing wrong

int redLed = 12;
int greenLed = 11;
int buzzer = 10;
int smokeA0 = A5;
// Your threshold value
int sensorThres = 400;

void setup() {
  pinMode(redLed, OUTPUT);
  pinMode(greenLed, OUTPUT);
  pinMode(buzzer, OUTPUT);
  pinMode(smokeA0, INPUT);
  Serial.begin(9600);
}

void loop() {
  int analogSensor = analogRead(smokeA0);

  Serial.print("Pin A0: ");
  Serial.println(analogSensor);
  // Checks if it has reached the threshold value
  if (analogSensor > sensorThres)
  {
    digitalWrite(redLed, HIGH);
    digitalWrite(greenLed, LOW);
    tone(buzzer, 1000, 200);
  }
  else
  {
    digitalWrite(redLed, LOW);
    digitalWrite(greenLed, HIGH);
    noTone(buzzer);
  }
  delay(100);
}

Report this ad
 Mediavine
View raw code

Vi/code]

I am worried that  is my  sensor not working or is there any problem with arduino.

Hi,
Can you draw your circuit from what you have built please, a picture of a drawn circuit will be ideal.


Also a picture of your project so we can see your component layout?
Do you have a DMM to measure voltages around your circuit?

How are you powering the project?

Tom... :slight_smile:

I powered it with the usb that is connected to pc only

And I have found that during testing the power led of sensor is not glowing
So does it mean the sensor is dead.
If it is dead how it can return with the value of 1023

For an analog input you don’t use “ pinMode” , so you can delete that line from setup .
I’d disconnect the buzzer too , we don’t know much about that , but you don’t need it and it may be taking a high load .

It looks like the sensor is not connected the right way.
Look here: https://www.pololu.com/file/0J309/MQ2.pdf

Does your sensor module look like this one?

Please check the wiring. Your device could read 1023 if the Ground wire was not connected.

You are supposed to keep the device powered up for 24 hours before trying to get a reading but I don't think that would cause a full-scale reading.

1 Like

Yes my sensor looks like this one only.

I have checked that i have properly connected the ground wire.

Look I have found this. Is this true
Cause I haven't used the sensor for more than 2 months

20200528_153408.jpg

Hi,
OPs sensor;


Have you tried adjusting the sensitivity control on the PCB?
Do you have a DMM?
Tom... :slight_smile:

Yes, I have tried adjusting sensitivity also.
Sorry but I don't have multimeter.

I want to know why the sensor's power led is not glowing

Hi,
Lift the wire from the output pin of the sensor and connect it to the Vcc pin of the sensor and read what the monitor indicates.
Then;
Move the wire from Vcc pin to gnd pin of the sensor and see what the monitor indicates.

What you will be doing is using A0 as a crude voltmeter.

On Vcc you should see 1023
On gnd you should see 0 or close to it.
Can you post a picture of your project please so we can see your component layout?

Tom... :slight_smile:

Vaibhav2710:
Look I have found this. Is this true
Cause I haven't used the sensor for more than 2 months

Leave the sensor powered for 24 hours and try again. Like I said: "You are supposed to keep the device powered up for 24 hours before trying to get a reading but I don't think that would cause a full-scale reading."

1 Like

TomGeorge:
Hi,
Lift the wire from the output pin of the sensor and connect it to the Vcc pin of the sensor and read what the monitor indicates.
Then;
Move the wire from Vcc pin to gnd pin of the sensor and see what the monitor indicates.

What you will be doing is using A0 as a crude voltmeter.

On Vcc you should see 1023
On gnd you should see 0 or close to it.

What type of pin I have to use for this (digital or analog)

Vaibhav2710:
What type of pin I have to use for this (digital or analog)

Analog pin. and keep in mind the heater in the mq2 can use about 800mw

notsolowki:
Analog pin. and keep in mind the heater in the mq2 can use about 800mw

Does it mean 800 Megawatts

Vaibhav2710:
Does it mean 800 Megawatts

No 800 milliWatts.
Tom... :slight_smile: