Shivani Singh
Published © GPL3+

PRAHAR – Predictive Industrial Gas Safety System

PRAHAR predicts exact seconds to danger — TTD algorithm warns workers BEFORE gas becomes critical.

IntermediateFull instructions provided10 hours73
PRAHAR – Predictive Industrial Gas Safety System

Things used in this project

Hardware components

Grove - Piezo Buzzer
Seeed Studio Grove - Piezo Buzzer
// Piezo Buzzer - Audio Alert System // Connected to Digital Pin 8 // // Function: // SAFE Zone (gas < 200) → No sound (Silent) // WARNING Zone (200–400) → Intermittent beeping // DANGER Zone (gas > 400) → Continuous sound (ON) // // The buzzer automatically turns OFF when gas levels return to safe range int buzzer = 8;
×1
Rotary Potentiometer, 10 kohm
Rotary Potentiometer, 10 kohm
// Potentiometer used to simulate MQ-2 gas sensor behavior // Clockwise = increasing gas concentration // Anti-clockwise = decreasing gas concentration // Will be replaced with MQ-2 sensor in real deployment
×1
Arduino UNO
Arduino UNO
// Arduino UNO R3 - Main Controller // Reads gas sensor data from analog pin A0 // Runs TTD prediction algorithm // Controls buzzer output on digital pin 8 // Communicates data via Serial Monitor (9600 baud)
×1
Male/Female Jumper Wires
Male/Female Jumper Wires
// Jumper Wire Connections (Male-Female) // // MQ-2 Sensor Connections: // VCC → Arduino 5V // GND → Arduino GND // A0 → Arduino A0 (Analog Input) // // Buzzer Connections: // Positive (+) → Arduino Pin 8 // Negative (-) → Arduino GND
×1
Solderless Breadboard Full Size
Solderless Breadboard Full Size
// Solderless Breadboard (Full-size, 830 tie-points) // Used for circuit prototyping without soldering // Allows easy placement and connection of components // Provides power distribution through internal rows and columns // Enables quick modifications and testing of the PRAHAR system
×1
MQ-2 Gas Sensor
// MQ-2 Gas Sensor Module used for detecting LPG, smoke and flammable gases // Provides both analog (A0) and digital (D0) output // Connected to Arduino for real-time gas monitoring // Threshold value set to trigger alert (LED/Buzzer) when gas level increases // Widely used in gas leakage detection and safety systems
×1
Red LED
// Red LED used as alert indicator for high gas concentration // Activated when MQ-2 sensor output crosses preset threshold // Interfaced with Arduino digital pin for automatic control // Connected in series with 220Ω resistor to limit current and ensure safe operation // Provides quick visual indication of hazardous conditions
×1
Yellow LED
// Yellow LED used as intermediate warning indicator for gas detection system // Activated when MQ-2 sensor detects moderate gas concentration // Indicates transition from safe to hazardous condition // Controlled via Arduino digital output based on threshold values // Connected in series with 220Ω resistor for safe current limiting
×1
Green LED
// Green LED used as normal condition indicator in gas detection system // Activated when MQ-2 sensor output is below threshold level // Confirms that the environment is safe and no gas leakage is detected // Controlled via Arduino digital pin based on sensor readings // Connected in series with 220Ω resistor for safe current limiting
×1
Resistor 220 ohm
Resistor 220 ohm
×1
220Ω Resistor
// 220Ω resistor used for current limiting in LED circuit // Connected in series with LEDs to regulate current according to Ohm’s Law // Prevents overcurrent conditions and protects components from damage // Helps maintain stable voltage and reliable circuit performance // Essential for safe interfacing of LEDs with Arduino outputs
×1

Software apps and online services

Arduino IDE
// Arduino IDE used for developing, compiling and uploading embedded code to Arduino // Interfaces MQ-2 gas sensor for real-time gas detection and LED control // Provides serial communication for monitoring sensor values and debugging // Essential tool for implementing and testing the gas detection system

Hand tools and fabrication machines

Laptop/PC
"For Tinkercad simulation and coding"
Tinkercad
"Used for circuit simulation and design"

Story

Read more

Schematics

PRAHAR_Gas_Detection_Simulation

3-page simulation document —
SAFE, DANGER and transition
states of PRAHAR gas detection
system using Arduino UNO R3,
Potentiometer and Piezo Buzzer.
TTD prediction algorithm working.

PRAHAR v3.0 — Gas Danger Prediction | Green

PRAHAR v3.0 — Upgraded LED Alert Demo

This video demonstrates the complete
v3.0 upgrade of PRAHAR system:

→ GREEN LED — Safe zone (gas normal)
→ YELLOW LED — Warning zone (gas rising)
→ RED LED + Buzzer — DANGER zone!

Key Feature:
TTD algorithm predicts exact seconds
to danger BEFORE critical level!

Simulation: Tinkercad
Hardware: Arduino UNO + MQ-2 sensor
Made in India. For India.

PRAHAR v3.0 — Circuit Design | Arduino

PRAHAR v3.0 — Complete Circuit Design

Components visible:
→ Arduino UNO — Main controller
→ Green LED (Pin 5) — Safe zone
→ Yellow LED (Pin 6) — Warning zone
→ Red LED (Pin 7) — Danger zone
→ 220Ω Resistors — LED protection
→ Potentiometer — MQ-2 simulation
→ Buzzer — Audio alert

TTD algorithm running on Arduino!
Simulation: Tinkercad
Made in India. For India.

PRAHAR_Complete_Demo

PRAHAR predictive gas safety system —
full simulation demo on Tinkercad.
Circuit: Arduino UNO R3 +
Potentiometer (MQ-2 simulation) +
Piezo Buzzer
Demonstration:
→ SAFE: Gas level normal,
buzzer silent
→ DANGER: Gas level 430+,
TTD algorithm triggers
buzzer BEFORE critical level!
Rate-based prediction
not just detection!

PRAHAR_Danger_Alert

PRAHAR DANGER state —
Gas level: 430+ PPM

TTD algorithm detected
rising gas trend and
triggered buzzer alert
BEFORE critical level!

This proves: PRAHAR predicts
danger — not just detects!
Made in India. For India.

PRAHAR_Live_Demo

PRAHAR live simulation demo —
Complete demonstration:
→ SAFE: Gas level normal,
buzzer silent
→ DANGER: Gas 430+ PPM,
TTD algorithm triggers
buzzer BEFORE critical level!
→ Gas decrease → SAFE again,
buzzer stops automatically
Rate-based prediction —
Not just detection!
Made in India. For India.

"PRAHAR Real Hardware Demo — Gas Detection & Danger Alert"

This is a real hardware
demonstration of PRAHAR —
Predictive Industrial Gas
Safety System.
Components used:
Arduino UNO, MQ-2 Gas Sensor
and Active Buzzer Module.
When gas concentration
exceeds safe limit —
buzzer triggers alert
immediately!
TTD algorithm predicts
danger in advance.

PRAHAR Safe Mode — Normal Gas Level Detected

PRAHAR Real Hardware — SAFE Mode.
MQ-2 sensor reading normal gas
levels. Buzzer is silent. System
is continuously monitoring for
any hazardous gas leak.
Workers are safe!

Code

PRAHAR_TTD_Gas_Detection

Arduino
Arduino code for PRAHAR —
Predictive Gas Safety System.
Features:
• Gas level monitoring
• TTD prediction algorithm
• SAFE/WARNING/DANGER zones
• Buzzer alert system
Not just detection — PREDICTION!
Made in India. For India.
int gasSensor = A0;
int buzzer = 8;
int prevGas = 0;
int dangerThreshold = 400;

void setup() {
  Serial.begin(9600);
  pinMode(buzzer, OUTPUT);
}

void loop() {
  int gasValue = analogRead(gasSensor);
  int rate = gasValue - prevGas;
  
  Serial.print("Gas: ");
  Serial.print(gasValue);
  
  if (gasValue > dangerThreshold) {
    Serial.println(" | DANGER!");
    digitalWrite(buzzer, HIGH);
  } else if (rate > 20) {
    Serial.println(" | WARNING!");
    digitalWrite(buzzer, HIGH);
    delay(200);
    digitalWrite(buzzer, LOW);
  } else {
    Serial.println(" | SAFE");
    digitalWrite(buzzer, LOW);
  }
  
  prevGas = gasValue;
  delay(1000);
}

PRAHAR_TTD_Upgraded_Code

Arduino
PRAHAR v2.0 — Real TTD Implementation
Upgraded features:
• Exact TTD calculation in seconds
• Early warning BEFORE danger level
• Rate-based prediction algorithm
• SAFE/WARNING/DANGER zones
Key innovation:
"System predicts exact time
before danger occurs!"
Not just detection — PREDICTION!
int gasSensor = A0;
int buzzer = 8;
int prevGas = 0;
int dangerThreshold = 400;

void setup() {
  Serial.begin(9600);
  pinMode(buzzer, OUTPUT);
  Serial.println("PRAHAR System Active...");
}

void loop() {
  int gasValue = analogRead(gasSensor);
  int rate = gasValue - prevGas;
  
  float ttd = 0;
  if (rate > 0) {
    ttd = (dangerThreshold - gasValue) / (float)rate;
  }
  
  Serial.print("Gas: ");
  Serial.print(gasValue);
  Serial.print(" | Rate: ");
  Serial.print(rate);
  Serial.print(" | TTD: ");
  Serial.print(ttd);
  Serial.print(" sec");
  
  if (gasValue > dangerThreshold) {
    Serial.println(" | *** DANGER! ***");
    digitalWrite(buzzer, HIGH);
  } 
  else if (rate > 0 && ttd < 10) {
    Serial.println(" | !! WARNING — TTD < 10 sec !!");
    digitalWrite(buzzer, HIGH);
    delay(200);
    digitalWrite(buzzer, LOW);
  } 
  else {
    Serial.println(" | SAFE");
    digitalWrite(buzzer, LOW);
  }
  
  prevGas = gasValue;
  delay(1000);
}

PRAHAR_v3_LED_TTD_Prediction

Arduino
PRAHAR v3.0 — Upgraded code with:
• Red/Yellow/Green LED alerts
• Exact TTD prediction in seconds
• Early Warning BEFORE danger!
• Rate-based prediction algorithm
Not just detection — PREDICTION!
Made in India. For India.
// ============================================
// PRAHAR v3.0 — Predictive Gas Safety System
// By: Shivani singh | Chemical Engg Student
// Innovation: TTD Prediction Algorithm
// Made in India. For India.
// ============================================

int gasSensor = A0;
int buzzer = 8;
int redLED = 7;
int yellowLED = 6;
int greenLED = 5;

int prevGas = 0;
int dangerThreshold = 400;
int warningThreshold = 250;

void setup() {
  Serial.begin(9600);
  pinMode(buzzer, OUTPUT);
  pinMode(redLED, OUTPUT);
  pinMode(yellowLED, OUTPUT);
  pinMode(greenLED, OUTPUT);
  Serial.println("PRAHAR v3.0 — System Ready");
  Serial.println("Predictive Gas Safety System");
}

void loop() {
  int gasValue = analogRead(gasSensor);
  int rate = gasValue - prevGas;

  // TTD Calculation (core innovation)
  float ttd = 0;
  if (rate > 0) {
    ttd = (float)(dangerThreshold - gasValue) / rate;
  }

  // Serial Monitor Output
  Serial.print("Gas PPM: ");
  Serial.print(gasValue);
  Serial.print(" | Rate: ");
  Serial.print(rate);
  Serial.print(" | TTD: ");
  if (rate > 0 && gasValue < dangerThreshold) {
    Serial.print(ttd);
    Serial.println(" seconds");
  } else {
    Serial.println("N/A");
  }

  // DANGER Zone
  if (gasValue > dangerThreshold) {
    Serial.println(">>> DANGER! Gas Critical!");
    digitalWrite(redLED, HIGH);
    digitalWrite(yellowLED, LOW);
    digitalWrite(greenLED, LOW);
    digitalWrite(buzzer, HIGH);
  }

  // EARLY WARNING — TTD < 10 seconds
  else if (rate > 0 && ttd < 10 && ttd > 0) {
    Serial.println(">>> EARLY WARNING! Danger in ");
    Serial.print(ttd);
    Serial.println(" seconds!");
    digitalWrite(redLED, LOW);
    digitalWrite(yellowLED, HIGH);
    digitalWrite(greenLED, LOW);
    digitalWrite(buzzer, HIGH);
    delay(200);
    digitalWrite(buzzer, LOW);
  }

  // WARNING Zone
  else if (gasValue > warningThreshold) {
    Serial.println(">> WARNING! Gas Rising!");
    digitalWrite(redLED, LOW);
    digitalWrite(yellowLED, HIGH);
    digitalWrite(greenLED, LOW);
    digitalWrite(buzzer, LOW);
  }

  // SAFE Zone
  else {
    Serial.println("> SAFE — Monitoring...");
    digitalWrite(redLED, LOW);
    digitalWrite(yellowLED, LOW);
    digitalWrite(greenLED, HIGH);
    digitalWrite(buzzer, LOW);
  }

  prevGas = gasValue;
  delay(1000);
}

Credits

Shivani Singh
1 project • 0 followers
Chem Engg Student | Arduino Developer | Built PRAHAR — Gas Safety System with TTD Algorithm | Made in India.

Comments