Vadakattu Bharath
Published

Coal Mine alerting system

Project can be used for college expo and it is built on custom PCB no need for bread boards, it will work efficiently

AdvancedFull instructions provided2 days232
Coal Mine alerting system

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
PCBWay Custom PCB
PCBWay Custom PCB
×1
0.96" OLED 64x128 Display Module
ElectroPeak 0.96" OLED 64x128 Display Module
×1
Buzzer
Buzzer
×1
DHT11 Temperature & Humidity Sensor (4 pins)
DHT11 Temperature & Humidity Sensor (4 pins)
×1
Grove - Gas Sensor(MQ2)
Seeed Studio Grove - Gas Sensor(MQ2)
×1
Grove - Vibration Sensor (SW-420)
Seeed Studio Grove - Vibration Sensor (SW-420)
×1
Programmable Wireless
Twilio Programmable Wireless
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Solder Wire, Lead Free
Solder Wire, Lead Free
Solder Flux, Soldering
Solder Flux, Soldering

Story

Read more

Schematics

AI generated circuit diagram

it gives the general connections

Code

code for Arduino

C/C++
final code for Arduino and python code for Twilio message is also available
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <DHT.h>

// OLED setup
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET -1
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

// Sensor pins
#define DHTPIN A1
#define DHTTYPE DHT11
#define MQ2_PIN A0
#define VIBRATION_PIN A2
#define BUZZER_PIN 7

DHT dht(DHTPIN, DHTTYPE);

// Thresholds
const int TEMP_THRESHOLD = 50;       
const int HUMIDITY_THRESHOLD = 80;    
const int SMOKE_THRESHOLD = 300;     
const int VIBRATION_THRESHOLD = 500; 

unsigned long vibrationStartTime = 0;
const unsigned long MIN_VIBRATION_DURATION = 2000;

void setup() {
  Serial.begin(9600);
  dht.begin();

  pinMode(BUZZER_PIN, OUTPUT);
  digitalWrite(BUZZER_PIN, HIGH); // Turn buzzer off initially
  pinMode(VIBRATION_PIN, INPUT);

  if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // 0x3C is common I2C address
    Serial.println(F("SSD1306 allocation failed"));
    for (;;);
  }

  display.clearDisplay();
  display.setTextSize(1);
  display.setTextColor(SSD1306_WHITE);
  display.setCursor(10, 25);
  display.println("Earthquake Monitor");
  display.display();
  delay(2000);
  display.clearDisplay();
}

void activateBuzzer() {
  digitalWrite(BUZZER_PIN, LOW);
}

void deactivateBuzzer() {
  digitalWrite(BUZZER_PIN, HIGH);
}

void loop() {
  float temp = dht.readTemperature();
  float humidity = dht.readHumidity();
  int smoke = analogRead(MQ2_PIN);
  int vibration = analogRead(VIBRATION_PIN);

  bool earthquakeDetected = false;
  if (vibration >= VIBRATION_THRESHOLD) {
    if (vibrationStartTime == 0) {
      vibrationStartTime = millis();
    } else if (millis() - vibrationStartTime >= MIN_VIBRATION_DURATION) {
      earthquakeDetected = true;
    }
  } else {
    vibrationStartTime = 0;
  }

  bool alert = (temp >= TEMP_THRESHOLD || humidity >= HUMIDITY_THRESHOLD || 
                smoke >= SMOKE_THRESHOLD || earthquakeDetected);

  if (alert) {
    activateBuzzer();
  } else {
    deactivateBuzzer();
  }

  // OLED display update
  display.clearDisplay();
  display.setCursor(0, 0);
  display.print("Temp: "); display.print(temp); display.println(" C");
  display.print("Hum: "); display.print(humidity); display.println(" %");
  display.print("Smoke: "); display.println(smoke);
  display.print("Vib: "); display.println(vibration);
  display.print("Earthquake: ");
  display.println(earthquakeDetected ? "YES" : "NO");
  if (alert) {
    display.setCursor(90, 50);
    display.setTextColor(SSD1306_BLACK, SSD1306_WHITE);
    display.println("ALERT");
    display.setTextColor(SSD1306_WHITE);
  }
  display.display();

  // Serial output
  Serial.print("Temp: ");
  Serial.print(temp);
  Serial.print("C | Hum: ");
  Serial.print(humidity);
  Serial.print("% | Smoke: ");
  Serial.print(smoke);
  Serial.print(" | Vib: ");
  Serial.print(vibration);
  Serial.print(" | Earthquake: ");
  Serial.print(earthquakeDetected ? "YES" : "NO");
  Serial.print(" | Alert: ");
  Serial.println(alert ? "ACTIVE" : "INACTIVE");

  delay(500);
}

Credits

Vadakattu Bharath
1 project • 0 followers

Comments