Site icon Circuit Ideas for You

MQ2 Gas Sensor Circuit with Arduino

The MQ2 Gas Sensor Circuit with Arduino is a low-cost sensor.

It can catch bad gas in air very quickly.

When we connect it with Arduino, we make small gas alarm system.

It reads gas level, show number on LCD and buzzer make sound when gas goes high.

This circuit is very simple to make and easy to learn.

It is good project for basic gas detection using Arduino.

Arduino Coding:

#include <Wire.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27,16,2);

int sensorPin = A0;
int buzzerPin = 8;
int gasValue = 0;
int limitValue = 300;

void setup() {
lcd.init();
lcd.backlight();
pinMode(buzzerPin, OUTPUT);
}

void loop() {
gasValue = analogRead(sensorPin);
lcd.setCursor(0,0);
lcd.print("Gas: ");
lcd.print(gasValue);

if(gasValue > limitValue){
digitalWrite(buzzerPin, HIGH);
lcd.setCursor(0,1);
lcd.print("Gas High! ");
} else {
digitalWrite(buzzerPin, LOW);
lcd.setCursor(0,1);
lcd.print("Safe ");
}
delay(300);
}

Coding Explanation:

Circuit Working:

MQ2 Gas Sensor Circuit Diagram with Arduino

Parts List:

Parts NameQuantity
Arduino UNO1
MQ2 Gas Sensor1
Buzzer 5V 1
I2C LCD 16×2 Display1

MQ2 has heater and sensor resistor.

When gas increases, sensor resistance falls.

Arduino reads this as higher analog value.

Code checks value.

If value is high then buzzer turns ON and LCD shows alert.

Formulas:

Below is the formula for MQ2 Gas Sensor Circuit with Arduino:

MQ2 output = voltage across load resistor RL.

Vout = (RL / (RL + RS)) * VCC

where,

When gas level rises, RS becomes small so Vout becomes high.

How to Build:

To build a MQ2 Gas Sensor Circuit with Arduino follow the below steps:

Conclusion:

This is simple project for MQ2 Gas Sensor Circuit with Arduino.

Arduino read sensor value and give warning by buzzer and LCD.

This project is good for safety and for basic learning.

References:

MQ2 gas sensor has high default sensor value

Exit mobile version