Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
33 changes: 33 additions & 0 deletions Domains/IoT/MiniProjects/Gas Leakage detection system/code.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#include <LiquidCrystal_I2C.h>
int a,a1,d=12,b=27;
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup() {
Serial.begin(115200);
pinMode(32, INPUT);
pinMode(d, OUTPUT);
pinMode(b, OUTPUT);
lcd.init();
lcd.backlight();
lcd.setCursor(0, 0);
lcd.println("Status :");
}
void loop() {
a = analogRead(32);
a1=map(a,843,4041,0,100);
lcd.setCursor(0, 1);
lcd.print(" ");
lcd.setCursor(0, 1);

if(a1>=65){
lcd.println ("Gas Detected!!");
digitalWrite(d,HIGH);
tone(b,1000);
}
else{
lcd.println ("Normal condition!!");
digitalWrite(d,LOW);
noTone(b);}


delay(500);
}
102 changes: 102 additions & 0 deletions Domains/IoT/MiniProjects/Gas Leakage detection system/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
πŸ”₯ Gas Detection System using ESP32 & MQ Sensor

This project detects the presence of gas or smoke using an analog gas sensor (e.g., MQ-2/MQ-135) connected to an ESP32 microcontroller. When the gas concentration exceeds a threshold, the system triggers a buzzer and displays a warning message on an I2C LCD display.

🧠 Features

🚨 Detects harmful gas concentrations in the environment

πŸ’‘ LCD display for real-time status updates

πŸ”” Buzzer alert for high gas levels

πŸ’Ύ Serial monitor for debugging

βš™οΈ Adjustable threshold for sensitivity

βš™οΈ Components Used

| Component | Description |
| ------------------------------- | ---------------------------------- |
| **ESP32** | Main controller |
| **MQ Gas Sensor (e.g., MQ-2)** | Detects gas levels |
| **16x2 I2C LCD Display (0x27)** | Displays gas status |
| **Buzzer** | Sounds alarm when gas detected |
| **LED (optional)** | Visual indicator for gas detection |
| **Connecting Wires** | For circuit connections |

🧩 Circuit Connections

| ESP32 Pin | Component | Description |
| --------- | ---------------- | --------------- |
| 32 | MQ Sensor Output | Analog input |
| 12 | LED | Alert indicator |
| 27 | Buzzer | Alarm output |
| SDA | LCD SDA | I2C data |
| SCL | LCD SCL | I2C clock |

πŸ’‘ Note: Ensure correct LCD I2C address (commonly 0x27 or 0x3F).

πŸ’» Code Explanation

πŸ”Έ Setup

Initializes the LCD and Serial Monitor.

Configures pins for sensor input, buzzer, and LED output.

πŸ”Έ Loop

Reads analog value from the gas sensor.

Maps it to a percentage scale (0–100).

Displays β€œNormal Condition” or β€œGas Detected!!” on the LCD.

Turns on the buzzer and LED if gas level β‰₯ 65%.

πŸ§ͺ Sample Output

LCD Display:

Status :

Gas Detected!!

Serial Output:

Gas value: 3250 β†’ Gas Detected!!

πŸš€ Future Enhancements

🌐 Send alerts to ThingSpeak or Blynk IoT Dashboard

πŸ“± Integrate mobile notifications (via Wi-Fi)

πŸ“Š Add data logging and visualization

🧰 Dependencies

Install the following libraries in the Arduino IDE:

LiquidCrystal_I2C

Wire

πŸ—οΈ How to Run

Connect all components as per the circuit table.

Upload the code to ESP32 using Arduino IDE.

Open the Serial Monitor at 115200 baud rate.

Observe LCD and buzzer behavior when exposed to gas.

✨ Author

Developed by: Shirsha Nag

Language: Arduino C

Board: ESP32
Loading