Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

How to Use MQ-4: Examples, Pinouts, and Specs

Image of MQ-4Design with MQ-4 in Cirkit Designer

Introduction

The MQ-4 is a gas sensor designed to detect methane (CH₄) and natural gas concentrations in the air. Manufactured by Flying Fish, this sensor operates on the principle of resistive change when exposed to gas, providing an analog output proportional to the gas concentration. It is widely used in applications such as gas leak detection, industrial safety systems, and home automation for monitoring air quality.

Explore Projects Built with MQ-4

Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!
Image of Arduino UNO and A9G GSM/GPRS GPS-Based Air Quality Monitoring System: A project utilizing MQ-4 in a practical application
Arduino UNO and A9G GSM/GPRS GPS-Based Air Quality Monitoring System

This circuit features an Arduino UNO microcontroller interfaced with an A9G GSM/GPRS+GPS module and an MQ2 gas sensor. The Arduino communicates with the A9G module via digital pins D11 and D10 for data transmission, and it reads analog gas concentration levels from the MQ2 sensor through analog pin A5. Both the A9G module and the MQ2 sensor are powered by the Arduino's 5V output, and all components share a common ground.

Open Project in Cirkit Designer
Image of Arduino UNO and MQ-4 Gas Sensor Interface: A project utilizing MQ-4 in a practical application
Arduino UNO and MQ-4 Gas Sensor Interface

This circuit is designed to interface an Arduino UNO with an MQ-4 gas sensor for the detection and measurement of gas concentrations. The Arduino provides power to the sensor and reads its analog output for processing. The embedded code for the Arduino is currently a template without specific functionality implemented.

Open Project in Cirkit Designer
Image of Multi-Gas Detection System with Arduino and MQ Sensors: A project utilizing MQ-4 in a practical application
Multi-Gas Detection System with Arduino and MQ Sensors

This circuit is designed to monitor various gases using a series of MQ gas sensors (MQ-2, MQ-3, MQ-4, MQ-5, MQ-6, MQ-7, MQ-8, MQ-9, and MQ-135), each providing digital outputs to an Arduino UNO microcontroller. The Arduino is also connected to a piezo speaker for audible alerts and multiple LEDs with resistors, likely for visual status indicators. An Adafruit TCA9548A I2C multiplexer is included, suggesting the potential for I2C sensor expansion or managing multiple I2C devices.

Open Project in Cirkit Designer

Common Applications:

Technical Specifications

The MQ-4 sensor is a robust and reliable component with the following key specifications:

Parameter Value
Manufacturer Flying Fish
Part ID MQ-4
Target Gases Methane (CH₄), Natural Gas
Operating Voltage 5V DC
Output Signal Analog (0-5V)
Preheat Time ≥ 24 hours (for stable readings)
Detection Range 200 ppm to 10,000 ppm
Heater Voltage (VH) 5V ± 0.1V
Heater Current (IH) ≤ 150 mA
Operating Temperature -20°C to 50°C
Humidity Range 33% to 85% RH
Lifetime ≥ 5 years

Pin Configuration and Descriptions

The MQ-4 sensor module typically comes with a 4-pin interface. Below is the pin configuration:

Pin Name Description
1 VCC Power supply pin. Connect to 5V DC.
2 GND Ground pin. Connect to the ground of the circuit.
3 AOUT Analog output pin. Provides a voltage proportional to the gas concentration.
4 DOUT Digital output pin. Outputs HIGH or LOW based on a preset threshold (adjustable).

Usage Instructions

How to Use the MQ-4 in a Circuit

  1. Powering the Sensor: Connect the VCC pin to a 5V DC power source and the GND pin to the ground.
  2. Reading Analog Output: Connect the AOUT pin to an analog input pin of a microcontroller (e.g., Arduino UNO) to measure the gas concentration.
  3. Using Digital Output: The DOUT pin can be connected to a digital input pin of a microcontroller or directly to an LED/buzzer for threshold-based alerts. The threshold can be adjusted using the onboard potentiometer.
  4. Preheating: Allow the sensor to preheat for at least 24 hours before taking stable readings.

Important Considerations and Best Practices

Example Code for Arduino UNO

Below is an example of how to interface the MQ-4 sensor with an Arduino UNO to read analog values:

// MQ-4 Methane Gas Sensor Example Code
// Connect AOUT to Arduino analog pin A0
// Connect VCC to 5V and GND to ground

const int analogPin = A0; // Analog pin connected to AOUT
int sensorValue = 0;      // Variable to store sensor reading

void setup() {
  Serial.begin(9600); // Initialize serial communication at 9600 baud
  Serial.println("MQ-4 Gas Sensor Test");
}

void loop() {
  sensorValue = analogRead(analogPin); // Read analog value from sensor
  float voltage = sensorValue * (5.0 / 1023.0); // Convert to voltage
  
  // Print the sensor value and voltage to the Serial Monitor
  Serial.print("Sensor Value: ");
  Serial.print(sensorValue);
  Serial.print(" | Voltage: ");
  Serial.print(voltage);
  Serial.println(" V");
  
  delay(1000); // Wait for 1 second before next reading
}

Troubleshooting and FAQs

Common Issues and Solutions

  1. No Output or Incorrect Readings:

    • Cause: Insufficient preheat time.
    • Solution: Ensure the sensor has been preheated for at least 24 hours before use.
  2. Fluctuating Readings:

    • Cause: Unstable power supply or environmental interference.
    • Solution: Use a regulated 5V power supply and ensure proper ventilation.
  3. Sensor Not Detecting Gas:

    • Cause: Sensor may be damaged or contaminated.
    • Solution: Inspect the sensor for physical damage or contamination. Replace if necessary.
  4. Digital Output Not Triggering:

    • Cause: Incorrect threshold setting.
    • Solution: Adjust the potentiometer on the module to set the desired threshold.

FAQs

Q1: Can the MQ-4 detect gases other than methane?
A1: While the MQ-4 is optimized for methane and natural gas, it may respond to other gases like propane or hydrogen, but with reduced sensitivity.

Q2: How do I calibrate the MQ-4 sensor?
A2: Expose the sensor to a known concentration of methane gas and adjust the potentiometer or use software calibration to map the analog output to the gas concentration.

Q3: Can I use the MQ-4 outdoors?
A3: The MQ-4 is not designed for outdoor use as extreme temperatures, humidity, and contaminants can affect its performance.

Q4: What is the lifespan of the MQ-4 sensor?
A4: The sensor has a typical lifespan of 5 years under normal operating conditions.

By following this documentation, users can effectively integrate the MQ-4 gas sensor into their projects for reliable methane and natural gas detection.