Arduino Project

Arduino Gas Leak Detector with MQ-2 Sensor

Kit purchase

Looking for parts? Check out our all-in-one kits below — packed with components, beginner-friendly guides, and tons of fun.

1.png__PID:e0199962-91ac-47de-843b-816a1d4face7

Name

Includes Arduino board

PURCHASE LINK

Ultimate Sensor Kit

Arduino Uno R4 Minima

Universal Maker Sensor Kit

×

Course Introduction

This Arduino project simulates a basic gas leak detection system using an MQ-2 gas sensor, a red LED, and a buzzer.

The sensor continuously monitors gas concentration. If the reading exceeds a set threshold, the buzzer sounds and the LED blinks to indicate danger.

Otherwise, the system remains silent and the LED stays off.

Note

If this is your first time working with an Arduino project, we recommend downloading and reviewing the basic materials first.

1.1 Install Arduino IDE(Important)
1.2 Introduction of Arduino IDE

Please follow the steps in the tutorial below to complete the binding and setup of Arduino Cloud and the Arduino WiFi board.
1.4 Arduino IoT Cloud

Required Components

In this project, we need the following components:

SN

COMPONENT INTRODUCTION

QUANTITY

PURCHASE LINK

1

Arduino UNO R4 Wifi

1

2

USB Type-C cable

1

×

3

Breadboard

1

4

Wires

Several

5

Buzzer Modudle

1

6

LED

1

7

MQ-2 Gas Sensor Module

1

8

1kΩ resistor

1

Wiring

gas_leak_iot.webp__PID:e4f7c9a1-7e25-4248-97be-f4eb5a9b22cc

Common Connections:

MQ-2 Gas Sensor Module
A0:
Connect to A0 on the Arduino.
GND: Connect to breadboard’s negative power bus.
VCC: Connect to breadboard’s red power bus.

Buzzer Modudle
I/O:Connect to 9 on the Arduino.
GND: Connect to breadboard’s negative power bus.
VCC: Connect to breadboard’s red power bus.

LED
Connect the LED anode to 6 on the Arduino, and the cathode to a 1kΩ resistor, then to the negative power bus on the breadboard.

Create a New IoT Project
After configuring the Arduino Cloud and the Arduino WiFi board, follow the steps below to complete the Arduino Cloud project setup

1.webp__PID:1f7301a4-2f4d-423b-baf1-f38a04a90ddb

Edit Value

2.webp__PID:de130c5f-4930-424a-b4a0-6730bd9e9e34
3.webp__PID:25119d87-f9da-4f51-b6e2-4012d528bc7e
4.webp__PID:16d75e3d-80fc-4991-a3e4-955dca62c511

Follow the steps below to configure the dashboard.
1.Create New Dashboard

6.webp__PID:da293eac-eee8-44a0-a339-f878cbcacd32

2.Add Widgets

7.webp__PID:f9dca78d-4253-408a-a792-211d441692a9

3.Link Variable

8.webp__PID:df6a72cb-d83d-4cd6-af94-b7b6f18b01739.png__PID:7875fad2-88e4-4041-b8dc-d2c0aa653573

4.Remember to click Done

10.webp__PID:43c5bc62-75b0-4a78-a001-93b05e14c186

After completing the above configuration, return to the Things page and open the sketch.

11.png__PID:18789d96-e22d-443f-883c-6f9e499e6bd7

When you have completed the configuration of the Things and Dashboard, as well as the connection and network setup of the Arduino WiFi board, the thingProperties.h and Sketch Secrets files will be generated automatically. If Sketch Secrets is not generated, please manually enter the connected SSID and OPTIONAL_PASS

Copy this code into Arduino Cloud.

11.webp__PID:76640201-0601-4ab3-856a-436092337c60

Don’t forget to select the board(Arduino UNO R4 WIFI) and the correct port before clicking the Upload button.