Experimenting with Gas Sensors and Arduino


Sensors

We have 4 different Gas Sensors on our web shop: MQ-2, MQ-3, MQ-7 and MQ-135.

All they work on same principle: sensor element is heated and it’s conductivity change with the gas concentration.

The heater require 5V and have 31 ohm resistance, so your power supply should provide 200mA of current for the sensor.

Sensor have both analog and digital output, the analog output is 0-5V, the digital output is frequency related to the output value.

MQ-2 is sensor of LPG, Propane, Methane and Hydrogen gas and can be used for domestic gas leak alarms
MQ-3 is sensor of Alcohol and Benzine and can be used for breath analizer
MQ-7 is sensor of Carbon monoxide CO and can be used for car gases analizer
MQ-135 is sensor of NH3, NOx, Alcohol, Benzine, Smoke, CO2 and can be used for quality of air analizer

We did some experiments today with all four sensors connecting them to OLIMEXINO-32U4 (Arduino Leonardo compatible).

The sensors have 4 pins: AO – Analog Output, DO – Digital output, GND, VCC-5V

MQ-1 MQ-2

OLIMEXINO-32U4 should be switched to work on 5V.

Three wires are used: AO from sensor to A0 of Arduino, VCC from sensor to 5V, GND from sensor to GND of Arduino.

The sketch is simple:

int sensorPin = A0;
int sensorValue = 0;
void setup() {
 Serial.begin(9600);
 pinMode(sensorPin, INPUT);
}
void loop() {
 sensorValue = analogRead(sensorPin);
 Serial.println(sensorValue);
}

It reads the sensor value and print it on Serial terminal.

Note that when sensor are power up they need about 1 minute to settle, in this time the heater heats up the sensor.

We experimented with Isopropile alcohol, Benzine, Lighter Gas, human breath of two different persons🙂

Here is the measured data:

MQ-2 normal air output  100
     Isopropile alcohol 540
     Ligther Gas        760
     Benzine            450
     Breath1            150
     Breath2            140
MQ-3 normal air output 180
     Isopropile alcohol 800
     Lighter Gas        400
     Benzine            700
     Breath1            220
     Breath2            270
 
MQ-7 normal air output  150
     Isopropile alcohol 750
     Lighter Gas        900
     Benzine            800
     Breath1            170
     Breath2            160
MQ-135 normal air output 130
      Isopropile alcohol 700
      Lighter Gas        760
      Benzine            450
      Breath1            150
      Breath2            140

the results are:

MQ-2 shows good sensibility to Lighter Gas

MQ-3 detects well Isopropile alcohol and Benzine

MQ-7 detects well Isopropile alcohol, Lighter gas and Benzine

MQ-135 detects well Isopropile alcohol, Lighter gas

13 Comments (+add yours?)

  1. anonima
    May 26, 2015 @ 20:03:00

    Amazing. Tutorials!

    Reply

  2. Ernő ZALKA (ern0)
    May 27, 2015 @ 00:02:08

    Do you have enough experienced alcohol testers?

    Reply

  3. anonima
    May 27, 2015 @ 00:41:27

    Can i connect this sensors to A20 micro? or
    How can i read this data sensor from network, with duino? shield wifi and http? SD card wifi?

    Reply

    • Wim
      May 28, 2015 @ 00:59:58

      Should work with anything that has a 0-5v analog input, but I don’t think the A20 boards have one. The easiest thing might be to connect it to an Arduino (or arduino-clone) and connect that to an internet-capable device with USB.

      Or maybe you can use the digital output from the sensor and connect it to GPIO input on the A20? Electrically that should work just fine (might need a couple resistors to do level shifting) but I don’t know about software to read the input pin and tell you what the reading is.

      Technically I bet you could even connect it to an ESP8266 module running custom firmware, that would be cool.

      Reply

  4. anonima
    May 27, 2015 @ 00:45:53

    And, how do you think is the best way to put this in exterior? Thanks

    Reply

  5. Chang
    Jun 16, 2015 @ 11:51:50

    Hi, how do you use the digital output of the MQ135 with a Raspberry Pi? Kindly advise. Thanks!!

    Reply

  6. Erick Varela
    Jul 30, 2015 @ 05:34:02

    do you have a datasheet with a legible legend? the characteristic sensitivity curves only AIR and NH3 is readable, I can’t say what the other curves/lines are or what gas are referring to.

    Reply

  7. Rahul
    Oct 30, 2015 @ 08:54:02

    Hi, Could you please tell what is the formula you used for getting specific CO2 and NH3 values from MQ135?
    Thanks

    Reply

  8. Sebastien
    Apr 12, 2016 @ 15:34:27

    Hello sir, i’ve tried using this code with a MQ135, but the only value that is returning to the arduino is 1023, is it a common problem ? and do you know where it comes from ?
    Thanks for your time

    Reply

  9. Jb Tanguy
    Jul 12, 2016 @ 17:08:06

    Hello,
    I would like to know how you did for getting back data from the sensor MQ135 for different gases ?

    MQ-135 normal air output 130
    Isopropile alcohol 700
    Lighter Gas 760
    Benzine 450
    Breath1 150
    Breath2 140

    I am working with an Arduino Uno and the MQ135 module and I just can read data but I don’t know how to do for different gases.
    Thanks

    Reply

  10. Sascha
    Aug 24, 2016 @ 22:22:43

    Is it possible to read the data and give the output in ppm? What means “Normal Air Output 100”. Do you calibrate the sensor ?

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: