Earthquake Detector using Arduino and MPU-6050 (original) (raw)

Earthquake Detector using Arduino and MPU6050 sensor: Earthquake detector is a device that detects earthquake shocks. According to research, approximately 800,000 earthquakes occurs in a year which kills so many lives and destroys buildings. Our project is a small effort to overcome the loss which occurs due to the earthquake. This detector can detect the minor shocks and alarm you to evacuate to a safe place. The most important component of this detector is MPU 6050 module which we will talk later. Arduino is the brain of this detector, LCD is used to display message and Led and buzzer is used as indicators.

Block Diagram Earthquake Detector using Arduino Earthquake Detector using Arduino block diagram

Components Required

Here are some feature MPU6050

Pin description of MPU6050 module:

  1. Vcc: Supply voltages of 3.3 to this pin.
  2. GND: This pin connected to ground.
  3. SCL: I2C Serial Clock Pin.
  4. SDA: I2C Serial Data Pin.
  5. XDA: I2C Master Data pin for an external sensor.
  6. XCL: I2C Master Clock pin for an external sensor.
  7. AD0: I2C Slave Address LSB.
  8. INT: Interrupt digital output pin.

Circuit Diagram of Earthquake Detector using Arduino Earthquake Detector using Arduino circuit diagram

Working of Earthquake Detector using Arduino block diagram

The Arduino first of all initialize MPU 6050. Check the sleep mode and a clock signal from module then started reading the values. There are maximum and minimum values are declared in the code it checks if the value is greater or smaller than the desired values then it starts the buzzer, led and display message “***Earthquake***”o n the LCD. If the values are normal then it does nothing.

Implementation of Earthquake Detector using Arduino

Earthquake detector using Arduino

Serial Plotter for Earthquake Detector using Arduino

plotter

Code of Earthquake Detector using Arduino

#include <LiquidCrystal.h>

#include <Wire.h>

#include <MPU6050.h>

#define minval -5

#define maxval 3

MPU6050 mpu;

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup()

{   lcd.begin(16, 2);

    Serial.begin(115200);

    pinMode(7,OUTPUT);

    pinMode(8,OUTPUT);

    lcd.print("   EarthQuake ");

    lcd.setCursor(0, 1);

    lcd.print("   Detector");

    delay (2000);

    lcd.clear();

  // Initialize MPU6050

  Serial.println("Initialize MPU6050");

  while(!mpu.begin(MPU6050_SCALE_2000DPS, MPU6050_RANGE_2G))

  { Serial.println("Could not find a valid MPU6050 sensor, check wiring!");

    delay(500);}

  mpu.setThreshold(3); 

  // Check settings

  checkSettings();

}

void checkSettings()

{

  Serial.println();

  Serial.print(" * Sleep Mode:        ");

  Serial.println(mpu.getSleepEnabled() ? "Enabled" : "Disabled");

  Serial.print(" * Clock Source:      ");

  switch(mpu.getClockSource())

  {case MPU6050_CLOCK_KEEP_RESET:     Serial.println("Stops the clock and keeps the timing generator in reset"); break;

    case MPU6050_CLOCK_EXTERNAL_19MHZ: Serial.println("PLL with external 19.2MHz reference"); break;

    case MPU6050_CLOCK_EXTERNAL_32KHZ: Serial.println("PLL with external 32.768kHz reference"); break;

    case MPU6050_CLOCK_PLL_ZGYRO:      Serial.println("PLL with Z axis gyroscope reference"); break;

    case MPU6050_CLOCK_PLL_YGYRO:      Serial.println("PLL with Y axis gyroscope reference"); break;

    case MPU6050_CLOCK_PLL_XGYRO:      Serial.println("PLL with X axis gyroscope reference"); break;

    case MPU6050_CLOCK_INTERNAL_8MHZ:  Serial.println("Internal 8MHz oscillator"); break;

  }

  Serial.print(" * Gyroscope:         ");

  switch(mpu.getScale())

  {case MPU6050_SCALE_2000DPS:        Serial.println("2000 dps"); break;

    case MPU6050_SCALE_1000DPS:        Serial.println("1000 dps"); break;

    case MPU6050_SCALE_500DPS:         Serial.println("500 dps"); break;

    case MPU6050_SCALE_250DPS:         Serial.println("250 dps"); break:}

  Serial.print(" * Gyroscope offsets: ");

  Serial.print(mpu.getGyroOffsetX());

  Serial.print(" / ");

  Serial.print(mpu.getGyroOffsetY());

  Serial.print(" / ");

  Serial.println(mpu.getGyroOffsetZ());

  Serial.println();}

void loop()

{   Vector rawGyro = mpu.readRawGyro();

  Vector normGyro = mpu.readNormalizeGyro();

  Serial.print(" Xraw = ");

  Serial.print(rawGyro.XAxis);

  Serial.print(" Yraw = ");

  Serial.print(rawGyro.YAxis);

  Serial.print(" Zraw = ");

  Serial.println(rawGyro.ZAxis); 

if(normGyro.XAxis > maxval || normGyro.XAxis < minval && normGyro.YAxis > maxval || normGyro.YAxis  < minval && normGyro.ZAxis > maxval || normGyro.ZAxis  < minval)

{ digitalWrite(7,HIGH);

  digitalWrite(8,HIGH);

  delay(300);

  digitalWrite(7,HIGH);

  digitalWrite(8,HIGH);

  delay(300);

  lcd.clear();

  lcd.print("EarthQuake");

  delay (1000);

  lcd.clear();}

 else{digitalWrite(7,LOW);

 digitalWrite(8,LOW);}

  Serial.print(" Xnorm = ");

  Serial.print(normGyro.XAxis);

  Serial.print(" Ynorm = ");

  Serial.print(normGyro.YAxis);

  Serial.print(" Znorm = ");

  Serial.println(normGyro.ZAxis);

  delay(10);}

video lecture Earthquake Detector using Arduino

Arduino Components Amazon Links
Arduino Starter Kit Buy Now
Arduino Development Kit Buy Now
Arduino Smart Robot Car Kit V4 Buy Now
Arduino Sensors Kit Buy Now