Project tutorial
MQ-4 Natural Gas Sensor Experiment Based on Arduino

MQ-4 Natural Gas Sensor Experiment Based on Arduino

This project uses sensors to monitor indoor natural gas on the basis of Arduino, and will sound the alarm if the gas leak exceeds the limit.

  • 995 views
  • 1 comment
  • 7 respects

Components and supplies

Apps and online services

About this project

Thisproject uses sensors to monitor indoor natural gas on the basis of Arduino, andwill make alarm if the natural gas leak exceeds the limit.

Material:

  • MQ-4Natural Gas Sensor
  • ArduinoUno with Network Screening
  • Breadboard

Note: You can redeem these in PCBWay, please support me by register this invited PCBWay link.

As a natural gas sensor, the MQ-4 Natural Gas Sensor is a fast and reliable sensor with a high sensitivity to natural gas and methane, also good sensitivity to propane and butane. This natural gas sensor has a long life and low cost and is widely used for gas leak detection. At the same time, two LED lights are used in the project to display the gas concentration:

  • Green light: it means the natural gas concentration is belowthe critical value.
  • Red light: alert! The natural gas concentration has exceeded the critical value.

The MQ-4Arduino sensor has four pins:

  • Positive Vcc (+5V)
  • Ground GND
  • Digital output
  • Analog output

Here is the wiring diagram:

In the schematic, there are two resistors connected to the Arduino digital pins and LEDs. The resistance is 220 Ohm

Here isthe code:

intpinRedLed = 11;
intpinGreenLed = 8;
intpinSensor = A5;
intTHRESHOLD = 250;
voidsetup() {
pinMode(pinRedLed, OUTPUT);
pinMode(pinGreenLed, OUTPUT);
pinMode(pinSensor, INPUT);
Serial.begin(9600);
}
voidloop() {
int analogValue = analogRead(pinSensor);
Serial.println("Val: " +analogValue);
digitalWrite(pinGreenLed, HIGH);
if (analogValue >= THRESHOLD) {
digitalWrite(pinGreenLed, LOW);
digitalWrite(pinRedLed, HIGH);
}
else {
digitalWrite(pinRedLed, LOW);
}
delay(5000);
}

The green LED remains light up unless the natural gas concentration exceeds the threshold, the red LED will lights up.

Comments

Similar projects you might like

Digital Oscilloscope Experiment Based on Arduino

Project tutorial by Andrew85

  • 1,803 views
  • 3 comments
  • 11 respects

Smoke Detection using MQ-2 Gas Sensor

by Aritro Mukherjee

  • 213,130 views
  • 36 comments
  • 133 respects

Arduino Based Digital Temperature Sensor

Project showcase by Abishek Bhalaaji

  • 10,103 views
  • 0 comments
  • 11 respects

How to Connect MQ2 Gas Sensor to Arduino

by Junez Riyaz

  • 1,195 views
  • 0 comments
  • 0 respects

WIZnet Interior Sensor Board

Project tutorial by Jade Perreault

  • 551 views
  • 0 comments
  • 0 respects

Using the YL-39 + YL-69 Soil Humidity Sensor with Arduino

Project tutorial by Sorin Trimbitas

  • 28,112 views
  • 6 comments
  • 17 respects
Add projectSign up / Login