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

Getting Started with Robotic Operating System (ROS) and JetRacer AI Kit
Barrier Gate with micro:bit and MakeCode
Play MP3 File on Maker Pi Pico Using CircuitPython
Remote Jetson Nano using SSH with Visual Studio Code
3.3V Serial LCD with Raspberry Pi Pico via SPI or I2C
Tutorials of Cytron Technologies Scroll to Top