Phipps Electronics

FREE SHIPPING OVER $199

30,000+ ORDERS

WORLDWIDE SHIPPING

SSL SECURED

Using the MQ Series of Gas Sensors with Arduino

INTRODUCTION:

This tutorial details the MQ- # module, its functions, and the method to build a simple project using the MQ gas sensor module and an Arduino.

MQ GAS SENSOR MODULE:

The MQ gas sensor module has a built-in gas sensor and sensitivity adjustment knob. The module outputs an analog signal related to the amount of specific gas it senses and a digital signal with a sensitivity adjustment. These sensors are gas specific, which means that each type of gas has a specific model.

MQ GAS SENSOR MODULES
Figure 1: MQ GAS SENSOR MODULES

PIN OUT:

The MQ Gas Sensor Module has four pins.

PinDescription
AOAnalog Output
DODigital Output
GNDGround
VCCModule Power Supply (5VDC)

HOW DOES IT WORK?

The MQ gas sensor module has a sensor that detects specific gas depending on its model. The module outputs analog signal from 0-1023. The higher the value, the higher the amount of the gas present in the air. The module also has a digital output; high output indicates a high amount of gas present in the atmosphere. Sensitivity is adjusted with the turning of the potentiometer knob on the module.

PROJECT – AIR GAS MONITOR

This project will demonstrate how the MQ gas sensor module detects the amount of gas in the air and displays this value in the serial monitor.

PROJECT COMPONENTS REQUIRED:

  • Arduino Uno Board (1 pc.)
  • MQ Gas sensor module (1 pc.)
  • Jumper Wires

WIRING DIAGRAM: 

The MQ Gas Sensor module pins are connected to the Arduino Uno board as follows:

Module PinUNO Board Pin
AOA0
DO3
GNDGND
VCC5V

CODE:

//MQ gas sensor pins
#define mqDigital 3
#define mqAnalog A0

void setup() {
  //Start serial monitor
  Serial.begin(9600);
  //pinmodes
  pinMode(mqDigital,INPUT);
  pinMode(mqAnalog,A0);
}

void loop() {
  //display analog reading
  Serial.println(analogRead(mqAnalog));
  //check digital signal
  if (digitalRead(mqDigital) == HIGH){
    Serial.println("Gas Detected");
  }
}


PROJECT TEST:

Wire the components to the Arduino as demonstrated in the wiring diagram. Connect the Arduino to a PC and upload the program. Open the Serial Monitor in the Arduino IDE and the amount of gas detected in the air will be displayed when the threshold of the gas sensitivity is reached.

Scroll to Top