Gas Detector Using The MQ2 Sensor on Maker NANO

Make your own gas leak detector today!

INTRODUCTION

The MQ-2 Gas sensor can detect or measure gasses like LPG, Alcohol, Propane, Hydrogen, CO, and even methane. With this sensor, we can build a gas leak detector to check if there is a gas leak and send a notification to our mobile phone. Watch this video to know how to make a gas detector using Maker NANO.

HARDWARE PREPARATION

This tutorial use :

Sample Code

This is the sample code used for this tutorial. Try it!

#define MQ2 A0
#define GREEN_LED 4
#define YELLOW_LED 5
#define RED_LED 6
#define PIEZO 8
int sensorValue = 0;
void setup()
{
Serial.begin(9600); // Initialize serial communications with the PC
pinMode(RED_LED, OUTPUT);
pinMode(GREEN_LED, OUTPUT);
pinMode(YELLOW_LED, OUTPUT);
pinMode(PIEZO, OUTPUT);
pinMode(MQ2, INPUT);
digitalWrite(GREEN_LED, HIGH);
}
void loop()
{
sensorValue = analogRead(MQ2);
Serial.println(sensorValue);
if (sensorValue > 300)
{
digitalWrite(GREEN_LED, LOW);
digitalWrite(RED_LED, HIGH);
tone(PIEZO, 1000, 300);
delay(700);
}
else
{
noTone;
digitalWrite(GREEN_LED, HIGH);
digitalWrite(RED_LED, LOW);
}
}
view raw smoke_detector hosted with ❤ by GitHub

Thank you

Thank you for reading this tutorial and we hope it helps your project development. If you have any technical inquiries, please post at Cytron Technical Forum.

3 thoughts on “Gas Detector Using The MQ2 Sensor on Maker NANO”

  1. Hiya, is it possible to combine this build up with esp32 built up by spliting the cable connecting the MQ2 sensor?

  2. MUHAMMAD FITRI BIN MOHD AHMARI

    hye. i just want o know…how to make it the project can send a notification to our mobile phone? how about the coding ?

Leave a Comment

Your email address will not be published.

Share this Tutorial

Share on facebook
Share on whatsapp
Share on email
Share on print
Share on twitter
Share on pinterest
Share on facebook
Share on whatsapp
Share on email
Share on print
Share on twitter
Share on pinterest

Latest Tutorial

Object Sense With Servo Using Maker Pi RP2040
Build Otto DIY Robot Using Maker Pi RP2040
Raspberry Pi RP2040 vs STM32F1 vs SAMD21G18 vs ESP32-S2
The Easiest Way to Print Temperature Tower Using Cura 4.9.1 Plugins
IoT on Raspberry Pi Pico using CircuitPython and Adafruit IO
Tutorials of Cytron Technologies Scroll to Top