Detect Methane Gas using MQ-4

Introduction

This experiment demonstrates how to use the MQ-4 sensor to detect methane gas in the environment.

MQ-4 Sensor

Components Needed

Circuit Setup

  1. Connect the MQ-4 sensor to the Arduino (VCC, GND, and analog output pin).

The MQ-4 sensor detects methane gas and outputs a voltage proportional to the concentration of the gas.

Methane Detection Circuit Setup

Code for Methane Detection

Upload the following code to your Arduino to measure methane gas levels:


const int mq4Pin = A0;
int sensorValue;

void setup() {
  Serial.begin(9600);
}

void loop() {
  sensorValue = analogRead(mq4Pin);
  Serial.print("Methane Concentration: ");
  Serial.println(sensorValue);
  delay(1000);
}
            

Explanation

The MQ-4 sensor reacts to methane gas, producing an analog voltage proportional to the gas concentration. The Arduino reads this value and displays it on the serial monitor.

Troubleshooting