• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Circuit Ideas for You

Get free circuit ideas online.

  • Home
  • Privacy Policy
  • About
Home » MQ2 Gas Sensor Circuit with Arduino

MQ2 Gas Sensor Circuit with Arduino

Last updated on 29 June 2026 by Admin-Lavi Leave a Comment

The MQ2 Gas Sensor Circuit with Arduino is a low-cost sensor, as 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.

Also, this circuit is very simple to make and easy to learn and it is good project for basic gas detection using Arduino.

Arduino Code:

#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:

  • LCD library works with I2C LCD.
  • SensorPin reads analog gas value from MQ2.
  • BuzzerPin becomes HIGH when gasValue is more than limitValue.
  • LCD shows gasValue and warning message.
  • Delay slows loop to read clearly.

Circuit Working:

MQ2 Gas Sensor Circuit Diagram with Arduino

Parts List:

ComponentsQuantity
Arduino UNO1
MQ2 Gas Sensor1
Buzzer 5V1
I2C LCD 16×2 Display1

To begin with, MQ2 has heater and sensor resistor and when gas increases, sensor resistance falls; then Arduino reads this as higher analog value.

After that, code checks value and 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,

  • RL is the load resistor which is a fixed resistor on the sensor.
  • RS is the sensor resistance which changes when gas level changes.
  • VCC is the supply voltage of 5V.

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:

  • First, take all the parts as shown in circuit diagram.
  • Next, MQ2 VCC pin connect to Arduino 5V, MQ2 GND pin connect to Arduino GND, MQ2 AO pin connect to Arduino A0 and MQ2 DO pin connect to Arduino digital pin D7
  • Then buzzer positive connect to Arduino pin and buzzer negative connect to GND
  • Now I2C LCD VCC pin connect to 5V and I2C LCD GND pin connect to GND
  • After that, I2C LCD SDA pin connect to Arduino A4 and I2C LCD SCL pin connect to Arduino A5

Conclusion:

To conclude, this is simple project for MQ2 Gas Sensor Circuit with Arduino and then Arduino read sensor value and give warning by buzzer and LCD.

Also, this project is good for safety and for basic learning.

Filed Under: Alarm Circuits, Arduino Projects, Security and Protection, Sensors and Detectors

About Admin-Lavi

Lavi is a B.Tech electronics engineer with a passion for designing new electronic circuits. Do you have questions regarding the circuit diagrams presented on this blog? Feel free to comment and solve your queries with quick replies

Previous Post: « Gas Alarm Circuit using MQ Sensor and Buzzer
Next Post: Smoke Detector Circuit using IC LM358 »

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar




Categories

  • 555 Timer Projects (137)
  • Alarm Circuits (81)
  • Amplifier Circuits (94)
  • Arduino Projects (103)
  • Audio Circuits (189)
  • Automation Circuits (150)
  • Automobile Circuits (40)
  • Battery Charger Circuits (88)
  • DIY Projects (435)
  • Free Energy (12)
  • Heater and Temperature Controllers (32)
  • High Voltage (24)
  • Hobby Circuits (241)
  • Indicator Circuits (63)
  • Inverter Circuits (17)
  • IoT projects (12)
  • LDR Circuits (47)
  • LED and Lamps (201)
  • Meters and Testers (44)
  • Mini Projects (390)
  • Motor Controllers (26)
  • Oscillator Circuits (70)
  • Power Supply Circuits (244)
  • Radio Frequency (8)
  • Remote Control Circuits (12)
  • Renewable energy (20)
  • Security and Protection (128)
  • Sensors and Detectors (236)
  • Solar Circuits (31)
  • Timer Circuits (63)
  • Transistor Circuits (178)
  • Transmitter Circuit (19)
  • Tutorials (33)
  • Voltage Regulator (55)
  • Water Level Controller (10)

Recent Posts

  • Low Current Controlled Battery Charger Circuit using LM723 IC
  • 741 Op-Amp Treble Booster Circuit
  • Simple Diode and Transistor Based Audio Limiter Circuit
  • Simple 500mW Speaker Driver Circuit
  • Easy DIY LM386 Audio Amplifier Circuit

Recent Comments

  1. Admin-Lavi on High Voltage Fence Charger Circuit
  2. etere on High Voltage Fence Charger Circuit
  3. Admin-Lavi on High Voltage Fence Charger Circuit
  4. egidio grzinic on High Voltage Fence Charger Circuit
  5. Logic OR Gate Circuit using Transistors - Circuit Ideas for You on Automatic Street Light Circuit using LDR

Copyright © 2026 | New Circuit Ideas