0% found this document useful (0 votes)
69 views12 pages

Arduino Gas Leak Detector

The document outlines the design and implementation of an Arduino-based gas leak detector using components like the MQ-2 sensor, buzzer, LEDs, and optional GSM module for SMS alerts. It includes circuit design, Arduino code examples, and optional enhancements for improved functionality. Additionally, it provides step-by-step instructions for creating a customizable enclosure for the device using CAD software.

Uploaded by

Daniel Rockson
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
69 views12 pages

Arduino Gas Leak Detector

The document outlines the design and implementation of an Arduino-based gas leak detector using components like the MQ-2 sensor, buzzer, LEDs, and optional GSM module for SMS alerts. It includes circuit design, Arduino code examples, and optional enhancements for improved functionality. Additionally, it provides step-by-step instructions for creating a customizable enclosure for the device using CAD software.

Uploaded by

Daniel Rockson
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Arduino Gas Leak Detector

Goal:

Detect gas leaks (like LPG, methane, or propane) and trigger alerts (buzzer, LED, or SMS).

🧰 Components Required
1. Arduino Uno (or Nano/ESP32)
2. MQ-2 or MQ-135 Gas Sensor – Detects gases like LPG, CO, methane, smoke
3. Buzzer – To sound an alarm
4. LEDs (Red & Green) – Visual alert
5. 16x2 LCD Display (optional) – Show gas concentration
6. Relay module (optional) – Control exhaust fan or shutoff valve
7. GSM module (like SIM800L) (optional) – Send SMS alerts
8. Power supply – 5V regulated or via USB
9. Breadboard & jumper wires

⚙️Basic Circuit Design


Connections

MQ-2 Sensor:

 VCC → 5V
 GND → GND
 A0 → A0 (Analog pin on Arduino)

Buzzer:


o → D8

o → GND

Red LED (Leak Alert):

 Anode → D9 (via 220Ω resistor)


 Cathode → GND
Green LED (Safe):

 Anode → D10 (via 220Ω resistor)


 Cathode → GND

LCD (if used):

 Connect via I2C for simplicity (SDA → A4, SCL → A5)

🧠 Arduino Code Example (Basic)


const int gasSensor = A0;

const int buzzer = 8;

const int redLED = 9;

const int greenLED = 10;

int threshold = 400; // Adjust based on calibration

void setup() {

pinMode(buzzer, OUTPUT);

pinMode(redLED, OUTPUT);

pinMode(greenLED, OUTPUT);

[Link](9600);

void loop() {

int sensorValue = analogRead(gasSensor);

[Link](sensorValue);

if (sensorValue > threshold) {


digitalWrite(buzzer, HIGH);

digitalWrite(redLED, HIGH);

digitalWrite(greenLED, LOW);

} else {

digitalWrite(buzzer, LOW);

digitalWrite(redLED, LOW);

digitalWrite(greenLED, HIGH);

delay(1000);

Optional Enhancements
1. Calibration – Let the sensor heat for 24–48 hours and define a better threshold.
2. SMS Alert – Add a SIM800L or SIM900 module to send a message on leak detection.
3. IoT Dashboard – Use ESP32 + Blynk or MQTT for live monitoring.
4. Battery Backup – Ensure the system works during a power outage.

Project Overview: Gas Leak Detector with ESP32, LCD & SMS
💡 Features:

 Detects gases like LPG, methane, and CO (using MQ-2 or MQ-135)


 Shows gas level on an LCD
 Triggers buzzer and LED alert on leak detection
 Sends SMS via SIM800L module
🧰 Components List
Component Description
ESP32 Dev Board Main controller
MQ-2 Sensor Gas detection (LPG, methane, smoke)
SIM800L Module For sending SMS alerts
I2C 16x2 LCD Display gas levels
Buzzer Audible alarm
Red & Green LEDs Visual indicators
Resistors (220Ω) For LEDs
Breadboard + Jumper wires For prototyping
Power Supply 5V 2A regulated for ESP32 + SIM800L

Wiring Diagram
MQ-2 Gas Sensor

 VCC → 5V
 GND → GND
 A0 → GPIO 36 (VP)

I2C LCD Display

 SDA → GPIO 21
 SCL → GPIO 22
 Needs I2C backpack

SIM800L Module

⚠️Needs level shifter or voltage divider for RX

 VCC → External 4V–4.2V supply (not ESP32 5V!)


 GND → GND
 TX → GPIO 16 (RX2)
 RX → GPIO 17 (TX2)

Buzzer


o → GPIO 27

o → GND
LEDs

 Red LED (Alert): GPIO 25 (with 220Ω resistor)


 Green LED (Safe): GPIO 26 (with 220Ω resistor)

💾 Libraries Needed
Install the following from Arduino Library Manager:

 LiquidCrystal_I2C
 SoftwareSerial (for SIM800L; might not be needed if using HardwareSerial on ESP32)

🧠 Sample Code
#include <Wire.h>

#include <LiquidCrystal_I2C.h>

#include <HardwareSerial.h>

#define GAS_SENSOR_PIN 36

#define RED_LED 25

#define GREEN_LED 26

#define BUZZER 27

LiquidCrystal_I2C lcd(0x27, 16, 2); // Adjust address if needed

HardwareSerial sim800(2); // Use Serial2 for SIM800L

const int threshold = 400; // Adjust after calibration

void setup() {

[Link](115200);

[Link](9600, SERIAL_8N1, 16, 17); // RX=16, TX=17

pinMode(RED_LED, OUTPUT);
pinMode(GREEN_LED, OUTPUT);

pinMode(BUZZER, OUTPUT);

pinMode(GAS_SENSOR_PIN, INPUT);

[Link]();

[Link]();

[Link](0, 0);

[Link]("Gas Detector");

delay(2000);

[Link]();

void loop() {

int gasValue = analogRead(GAS_SENSOR_PIN);

[Link](gasValue);

[Link](0, 0);

[Link]("Gas: ");

[Link](gasValue);

[Link](" "); // Clear leftovers

if (gasValue > threshold) {

digitalWrite(RED_LED, HIGH);

digitalWrite(GREEN_LED, LOW);

digitalWrite(BUZZER, HIGH);

[Link](0, 1);
[Link]("!!! LEAK ALERT !!!");

sendSMS("Gas leak detected! Value: " + String(gasValue));


delay(10000); // Avoid spamming SMS

} else {
digitalWrite(RED_LED, LOW);

digitalWrite(GREEN_LED, HIGH);

digitalWrite(BUZZER, LOW);

[Link](0, 1);
[Link]("Status: Safe ");

delay(2000); }

void sendSMS(String message) {

[Link]("AT+CMGF=1");

delay(1000);

[Link]("AT+CMGS="+1234567890""); // Replace with your number

delay(1000);

[Link](message);

delay(500);

[Link](26); // CTRL+Z to send

delay(5000);

Fritzing Diagram
step-by-step instructions to model a customizable, splash-proof ESP32 gas leak detector enclosure using
Fusion 360, FreeCAD, or Tinkercad.
Design Overview
 Enclosure Dimensions: 100 mm (L) × 70 mm (W) × 30 mm (H)
 Top Opening: For LCD (I2C 16x2) → 55 mm × 15 mm
 Side Slits: 5 vent slits on one side (20 mm × 2 mm × 2 mm each)
 Mounting Holes: Four 4 mm holes at the corners
 Snap-Lock Lid: Optional, or screw-on top

🧱 Step-by-Step Modeling (CAD-Agnostic)


🔹 1. Base Box

 Create a rectangular box: 100 mm × 70 mm × 30 mm


 Shell it from the top, leaving 2.5 mm wall thickness
 Bottom thickness: 2 mm

🔹 2. LCD Cutout (Top Face)

 Create a rectangular cutout: 55 mm × 15 mm


 Position it:
o Centered horizontally (X: 0)
o Offset Y: +15 mm from center (toward one short side)
 Cut through top wall

🔹 3. Ventilation Slits (Side Wall)

 On one long side:


o Create 5 rectangular slots: 20 mm × 2 mm
o Vertically spaced: 4 mm apart
o Start 8 mm from base and stack up

🔹 4. Mounting Holes (Corners)

 Create 4 holes:
o Diameter: 4 mm
o Center positions: ±45 mm (X), ±30 mm (Y) from center
 Through the bottom plate

🔹 5. Snap Lock or Lid

Option A: Snap Fit


 Design top lip (1 mm thick) with a step groove
 Add matching groove in the lid
 Add small chamfers or fillets for easy fit

Option B: Screw-on Lid

 Add 4 screw bosses (cylindrical pads inside corners)


 Add matching holes on lid with clearance

📦 Optional Features
 Cable holes: Add 8 mm diameter circular holes for sensor wires, SIM800L antenna, and USB port.
 Text labels: Add embossed or engraved labels (LCD, Power, Sensor, GSM).
 Wall-mount flanges: Extend sides with 5 mm tabs and extra mounting holes.

🧰 Tools
You can build this in:

 Fusion 360: Use “Shell,” “Combine,” and “Fillet” tools


 FreeCAD: Use Part or Part Design workbench with "Pocket" and "Pad"
 Tinkercad: Use “Hole” shapes and “Group” to subtract features

Tinkercad Enclosure Model

You can access and customize the enclosure model here:

👉 [Link]

Features of the Model

 ESP32 Mounting: Designed to securely hold an ESP32 development board.


 Ventilation: Includes side slits for airflow, suitable for gas sensors like the MQ-135.
 LCD Display Cutout: Top panel accommodates a 16x2 I2C LCD display.
 Additional Components: Space allocated for components such as the SIM800L GSM module, buzzer,
and indicator LEDs.
 Mounting Options: Features for wall-mounting or tabletop placement.

🧰 Customization Steps

To tailor the enclosure to your specific needs:


1. Duplicate the Design: Click on the link above and select "Duplicate and Tinker" to create your own
editable copy.
2. Adjust Dimensions: Modify the enclosure size to fit your components, ensuring adequate space for
wiring and airflow.
3. Add Cutouts: Use the "Hole" feature to create openings for the MQ-135 sensor, SIM800L antenna,
USB ports, and any other necessary access points.
4. Incorporate Mounting Features: Add holes or brackets for mounting the enclosure to a wall or other
surfaces.
5. Label Components: Utilize the "Text" tool to label different parts of the enclosure for clarity.

Once you've customized the design:

 Export as STL: Click on "Export" and choose the STL format for 3D printing.
 Prepare for Printing: Use slicing software like Cura to prepare the STL file for your 3D printer.
 Print the Enclosure: Print the enclosure using suitable filament material, considering factors like heat
resistance and durability.

You might also like